int client_read_team_size(const remote_process_client *client) { VERIFY(READ_ENUM(ct_message_type), MSG_TEAM_SIZE); return READ_INT32(); }
/*--[lit_i_read_directory]----------------------------------------------------- | | This reads the directory chunks from the piece and converts the list into | entry elements in the lit_file structure. | */ int lit_i_read_directory(lit_file * litfile, U8 * piece, int piece_size) { U8 * p = NULL; int nEntries, nRemaining, nChunks, chunk, idx, sizeChunk; entry_type * entry, * prev; if (!piece || (READ_U32(piece) != IFCM_TAG)) { lit_error(ERR_R, "Header Piece #3 is not the main directory! (TAG=%08lx)", (piece)?(READ_U32(piece)):0); return E_LIT_FORMAT_ERROR; } sizeChunk = READ_INT32(piece + 8); nChunks = READ_INT32(piece + 24); if ((32 + (nChunks * sizeChunk)) != piece_size) { lit_error(ERR_R, "IFCM HEADER (%d chunks of %d bytes) != %d total.", nChunks, sizeChunk, piece_size - 32); return E_LIT_FORMAT_ERROR; } prev = NULL; for (chunk = 0; chunk < nChunks; chunk++) { p = piece + 32 + (chunk * sizeChunk); /* This can either be AOLL or AOLI. * AOLI isn't useful for reading */ if (READ_U32(p) != AOLL_TAG) continue; nRemaining = READ_INT32(p + 4); if (nRemaining >= sizeChunk) { lit_error(ERR_R, "AOLL remaining count is NEGATIVE! (%d of %d) %x\n", (int)nRemaining, (int)sizeChunk, (int)nRemaining); return E_LIT_FORMAT_ERROR; } nRemaining = sizeChunk - (nRemaining + 48); nEntries = READ_U16(p + sizeChunk - 2); /* Sometimes, the nEntries doesn't get written. When this happens, * I don't know how many to read. Fortunately, there is "nRemaining", * and if everything is working fine, read_entry will consume JUST * enough bytes */ if (!nEntries) nEntries = 65535; p += 48; if (nRemaining < 0) return E_LIT_FORMAT_ERROR; for (idx = 0; idx < nEntries; idx ++) { if (nRemaining <= 0) break; entry = read_entry(&p, &nRemaining); if (!entry) { return E_LIT_FORMAT_ERROR; } if (!prev) { litfile->entry = entry; prev = entry; } else { prev->next = entry; prev = entry; } } } return 0; }