int lcb_pktinfo_ior_get(packet_info *info, rdb_IOROPE *ior, unsigned *required) { unsigned total = rdb_get_nused(ior); unsigned wanted = sizeof(info->res.bytes); if (total < wanted) { *required = wanted; return 0; } rdb_copyread(ior, info->res.bytes, sizeof(info->res.bytes)); if (!PACKET_NBODY(info)) { rdb_consumed(ior, sizeof(info->res.bytes)); return 1; } wanted += PACKET_NBODY(info); if (total < wanted) { *required = wanted; return 0; } rdb_consumed(ior, sizeof(info->res.bytes)); info->payload = rdb_get_consolidated(ior, PACKET_NBODY(info)); return 1; }
static void set_iterbuf(lcbio_CTX *ctx, lcbio_CTXRDITER *iter) { if ((iter->nbuf = rdb_get_contigsize(&ctx->ior))) { if (iter->nbuf > iter->remaining) { iter->nbuf = iter->remaining; } iter->buf = rdb_get_consolidated(&ctx->ior, iter->nbuf); } else { iter->buf = NULL; } }