bool ProtocolFileInfo::decode_body(const char *buf, int size) { int temp; ////result DECODE_INT(temp); m_fileinfo.result = (FileInfo::Result)temp; ////fid DECODE_STRING(m_fileinfo.fid); ////file name DECODE_STRING(m_fileinfo.name); ////file size DECODE_INT(m_fileinfo.size); ////chunk info DECODE_INT(temp); while(temp-- > 0) { ChunkPath chunkpath; //chunk id DECODE_STRING(chunkpath.id); //chunk ip DECODE_STRING(chunkpath.ip); //chunk port DECODE_INT(chunkpath.port); //index DECODE_INT(chunkpath.index); //chunk offset DECODE_INT(chunkpath.offset); m_fileinfo.add_chunkpath(chunkpath); } return true; }
bool ProtocolChunkPing::decode_body(const char *buf, int size) { ////chunk id DECODE_STRING(m_chunk_info.id); ////chunk ip DECODE_STRING(m_chunk_info.ip); ////chunk port DECODE_INT(m_chunk_info.port); ////disk space DECODE_INT64(m_chunk_info.disk_space); ////disk used DECODE_INT64(m_chunk_info.disk_used); return true; }
void RRGLevel::initWithDecoder(RRGCoding::Decoder* decoder) { DECODE_OBJECT(RRGCharacter, _character1); CC_SAFE_RETAIN(_character1); DECODE_OBJECT(RRGCharacter, _character2); CC_SAFE_RETAIN(_character2); DECODE_OBJECT(RRGCharacter, _character3); CC_SAFE_RETAIN(_character3); DECODE_VECTOR_OBJECTS(RRGCharacter, _vectChara); DECODE_MAP_OBJECTS(RRGCharacter, _mapChara); DECODE_INT(_testInt); DECODE_FLOAT(_testFloat); DECODE_STRING(_testString); DECODE_ARRAY(int, _intArray); DECODE_VALUEVECTOR(_valueVector); DECODE_VALUEMAP(_valueMap); DECODE_VECTOR(int, _intVector); DECODE_VECTOR(Vec2, _pointVector); DECODE_MAP(double, _doubleMap); DECODE_MAP(Rect, _rectMap); }
//解码大小为size的协议体数据buf.成功返回true,失败返回false. bool RequestSize::decode_body(const char* buf, int size) { int len = 0; //file name DECODE_STRING(m_file_name); return true; }
////解码协议体数据io_buffer.成功返回true,失败返回false. bool TemplateProtocol::decode_body(const char *buf, int size) { ////m_value DECODE_INT(m_value); ////m_str DECODE_STRING(m_str); return true; }
bool ProtocolFileInfoReq::decode_body(const char *buf, int size) { ////fid DECODE_STRING(m_fid); ////query chunk path char temp; DECODE_CHAR(temp); m_query_chunkpath = (bool)temp; return true; }
//解码大小为size的协议体数据buf.成功返回true,失败返回false. bool RespondSize::decode_body(const char* buf, int size) { int len = 0; //file size DECODE_INT64(m_file_size); //file name DECODE_STRING(m_file_name); return true; }
bool ProtocolChunkPingResp::decode_body(const char *buf, int size) { int temp; ////result DECODE_INT(temp); m_result = (bool)temp; ////chunk id DECODE_STRING(m_chunk_id); return true; }
bool ProtocolFileInfoSaveResult::decode_body(const char *buf, int size) { int temp; ////result DECODE_INT(temp); m_save_result.result = (FileInfoSaveResult::Result)temp; ////fid DECODE_STRING(m_save_result.fid); return true; }
//解码包体.成功返回0,否则返回-1; bool RequestData::decode_body(const char* buf, int size) { int len = 0; //file name DECODE_STRING(m_file_name); //start pos DECODE_INT64(m_start_pos); //size DECODE_INT(m_size); return true; }
bool ProtocolFileSaveResult::decode_body(const char *buf, int size) { int temp; //result DECODE_INT(temp); m_save_result.status = (FileSaveResult::Status)temp; ////fid DECODE_STRING(m_save_result.fid); ////seg index DECODE_INT(m_save_result.index); return true; }
bool ProtocolFileReq::decode_body(const char *buf, int size) { ////fid DECODE_STRING(m_file_req.fid); ////index DECODE_INT(m_file_req.index); ////offset DECODE_INT(m_file_req.offset); ////size DECODE_INT(m_file_req.size); return true; }
bool ProtocolFile::decode_body(const char *buf, int size) { int temp; ////flag DECODE_INT(temp); m_file_seg.flag = (FileSeg::FileFlag)temp; ////fid DECODE_STRING(m_file_seg.fid); ////name DECODE_STRING(m_file_seg.name); ////file size DECODE_INT(m_file_seg.filesize); ////seg offset DECODE_INT(m_file_seg.offset); ////seg index DECODE_INT(m_file_seg.index); ////seg size DECODE_INT(m_file_seg.size); ////data if(size<m_file_seg.size) return false; m_file_seg.data = buf; return true; }
static int init_sec_context(char *buf, int index, ei_x_buff *presult) { ei_x_buff result = *presult; /* {init_sec_context, {Idx, Service, Host, Input}} -> {ok, {Idx, Data}} | {error, Error} */ int arity; gss_buffer_desc in; gss_buffer_desc out; int res; char *service = NULL; char *hostname = NULL; long idx; OM_uint32 min_stat; memset(&in, 0, sizeof(in)); memset(&out, 0, sizeof(out)); EI(ei_decode_tuple_header(buf, &index, &arity)); EI(arity != 4); EI(ei_decode_long(buf, &index, &idx)); DECODE_STRING(&service); DECODE_STRING(&hostname); EI(decode_gssapi_binary(buf, &index, &in)); if (idx < 0) { idx = session_find_free(); if (idx < 0) ENCODE_ERROR("no_mem"); g_sessions[idx] = GSS_C_NO_CONTEXT; } else { if (idx < 0 || idx >= MAX_SESSIONS || !g_sessions[idx]) ENCODE_ERROR("bad_instance"); } res = init_user(&g_sessions[idx], service, hostname, &in, &out); if (!GSS_ERROR(res)) { const char *status = (res & GSS_S_CONTINUE_NEEDED)?"needsmore":"ok"; EI(ei_x_encode_atom(&result, status) || ei_x_encode_tuple_header(&result, 2) || ei_x_encode_long(&result, idx) || ei_x_encode_binary(&result, out.value, out.length) ); } else { EI(ei_x_encode_atom(&result, "error") || ei_x_encode_long(&result, res)); } error: if (service) free(service); if (hostname) free(hostname); if (in.value) gss_release_buffer(&min_stat, &in); if (out.value) gss_release_buffer(&min_stat, &out); *presult = result; return 0; }