Lines Matching refs:h

184 cdf_swap_header(cdf_header_t *h)  in cdf_swap_header()  argument
188 h->h_magic = CDF_TOLE8(h->h_magic); in cdf_swap_header()
189 h->h_uuid[0] = CDF_TOLE8(h->h_uuid[0]); in cdf_swap_header()
190 h->h_uuid[1] = CDF_TOLE8(h->h_uuid[1]); in cdf_swap_header()
191 h->h_revision = CDF_TOLE2(h->h_revision); in cdf_swap_header()
192 h->h_version = CDF_TOLE2(h->h_version); in cdf_swap_header()
193 h->h_byte_order = CDF_TOLE2(h->h_byte_order); in cdf_swap_header()
194 h->h_sec_size_p2 = CDF_TOLE2(h->h_sec_size_p2); in cdf_swap_header()
195 h->h_short_sec_size_p2 = CDF_TOLE2(h->h_short_sec_size_p2); in cdf_swap_header()
196 h->h_num_sectors_in_sat = CDF_TOLE4(h->h_num_sectors_in_sat); in cdf_swap_header()
197 h->h_secid_first_directory = CDF_TOLE4(h->h_secid_first_directory); in cdf_swap_header()
198 h->h_min_size_standard_stream = in cdf_swap_header()
199 CDF_TOLE4(h->h_min_size_standard_stream); in cdf_swap_header()
200 h->h_secid_first_sector_in_short_sat = in cdf_swap_header()
201 CDF_TOLE4(CAST(uint32_t, h->h_secid_first_sector_in_short_sat)); in cdf_swap_header()
202 h->h_num_sectors_in_short_sat = in cdf_swap_header()
203 CDF_TOLE4(h->h_num_sectors_in_short_sat); in cdf_swap_header()
204 h->h_secid_first_sector_in_master_sat = in cdf_swap_header()
205 CDF_TOLE4(CAST(uint32_t, h->h_secid_first_sector_in_master_sat)); in cdf_swap_header()
206 h->h_num_sectors_in_master_sat = in cdf_swap_header()
207 CDF_TOLE4(h->h_num_sectors_in_master_sat); in cdf_swap_header()
208 for (i = 0; i < __arraycount(h->h_master_sat); i++) { in cdf_swap_header()
209 h->h_master_sat[i] = in cdf_swap_header()
210 CDF_TOLE4(CAST(uint32_t, h->h_master_sat[i])); in cdf_swap_header()
215 cdf_unpack_header(cdf_header_t *h, char *buf) in cdf_unpack_header() argument
220 CDF_UNPACK(h->h_magic); in cdf_unpack_header()
221 CDF_UNPACKA(h->h_uuid); in cdf_unpack_header()
222 CDF_UNPACK(h->h_revision); in cdf_unpack_header()
223 CDF_UNPACK(h->h_version); in cdf_unpack_header()
224 CDF_UNPACK(h->h_byte_order); in cdf_unpack_header()
225 CDF_UNPACK(h->h_sec_size_p2); in cdf_unpack_header()
226 CDF_UNPACK(h->h_short_sec_size_p2); in cdf_unpack_header()
227 CDF_UNPACKA(h->h_unused0); in cdf_unpack_header()
228 CDF_UNPACK(h->h_num_sectors_in_sat); in cdf_unpack_header()
229 CDF_UNPACK(h->h_secid_first_directory); in cdf_unpack_header()
230 CDF_UNPACKA(h->h_unused1); in cdf_unpack_header()
231 CDF_UNPACK(h->h_min_size_standard_stream); in cdf_unpack_header()
232 CDF_UNPACK(h->h_secid_first_sector_in_short_sat); in cdf_unpack_header()
233 CDF_UNPACK(h->h_num_sectors_in_short_sat); in cdf_unpack_header()
234 CDF_UNPACK(h->h_secid_first_sector_in_master_sat); in cdf_unpack_header()
235 CDF_UNPACK(h->h_num_sectors_in_master_sat); in cdf_unpack_header()
236 for (i = 0; i < __arraycount(h->h_master_sat); i++) in cdf_unpack_header()
237 CDF_UNPACK(h->h_master_sat[i]); in cdf_unpack_header()
298 cdf_check_stream(const cdf_stream_t *sst, const cdf_header_t *h) in cdf_check_stream() argument
301 size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ? in cdf_check_stream()
302 CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h); in cdf_check_stream()
309 cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_check_stream_offset() argument
314 size_t ss = cdf_check_stream(sst, h); in cdf_check_stream_offset()
355 cdf_read_header(const cdf_info_t *info, cdf_header_t *h) in cdf_read_header() argument
362 cdf_unpack_header(h, buf); in cdf_read_header()
363 cdf_swap_header(h); in cdf_read_header()
364 if (h->h_magic != CDF_MAGIC) { in cdf_read_header()
367 (unsigned long long)h->h_magic, in cdf_read_header()
371 if (h->h_sec_size_p2 > 20) { in cdf_read_header()
372 DPRINTF(("Bad sector size %hu\n", h->h_sec_size_p2)); in cdf_read_header()
375 if (h->h_short_sec_size_p2 > 20) { in cdf_read_header()
377 h->h_short_sec_size_p2)); in cdf_read_header()
389 const cdf_header_t *h, cdf_secid_t id) in cdf_read_sector() argument
391 size_t pos = CDF_SEC_POS(h, id); in cdf_read_sector()
392 assert(CDF_SEC_SIZE(h) == len); in cdf_read_sector()
398 size_t len, const cdf_header_t *h, cdf_secid_t id) in cdf_read_short_sector() argument
400 size_t pos = CDF_SHORT_SEC_POS(h, id); in cdf_read_short_sector()
401 assert(CDF_SHORT_SEC_SIZE(h) == len); in cdf_read_short_sector()
402 if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) { in cdf_read_short_sector()
405 pos + len, CDF_SEC_SIZE(h) * sst->sst_len)); in cdf_read_short_sector()
420 cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat) in cdf_read_sat() argument
423 size_t ss = CDF_SEC_SIZE(h); in cdf_read_sat()
427 for (i = 0; i < __arraycount(h->h_master_sat); i++) in cdf_read_sat()
428 if (h->h_master_sat[i] == CDF_SECID_FREE) in cdf_read_sat()
433 h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec) || in cdf_read_sat()
436 SIZE_T_FORMAT "u\n", h->h_num_sectors_in_master_sat, i)); in cdf_read_sat()
441 sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i; in cdf_read_sat()
448 for (i = 0; i < __arraycount(h->h_master_sat); i++) { in cdf_read_sat()
449 if (h->h_master_sat[i] < 0) in cdf_read_sat()
451 if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h, in cdf_read_sat()
452 h->h_master_sat[i]) != CAST(ssize_t, ss)) { in cdf_read_sat()
453 DPRINTF(("Reading sector %d", h->h_master_sat[i])); in cdf_read_sat()
461 mid = h->h_secid_first_sector_in_master_sat; in cdf_read_sat()
462 for (j = 0; j < h->h_num_sectors_in_master_sat; j++) { in cdf_read_sat()
469 if (cdf_read_sector(info, msa, 0, ss, h, mid) != in cdf_read_sat()
484 if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h, in cdf_read_sat()
545 cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_long_sector_chain() argument
548 size_t ss = CDF_SEC_SIZE(h), i, j; in cdf_read_long_sector_chain()
552 scn->sst_dirlen = MAX(h->h_min_size_standard_stream, len); in cdf_read_long_sector_chain()
576 if ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h, in cdf_read_long_sector_chain()
594 cdf_read_short_sector_chain(const cdf_header_t *h, in cdf_read_short_sector_chain() argument
598 size_t ss = CDF_SHORT_SEC_SIZE(h), i, j; in cdf_read_short_sector_chain()
600 scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h)); in cdf_read_short_sector_chain()
622 if (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h, in cdf_read_short_sector_chain()
636 cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_sector_chain() argument
641 if (len < h->h_min_size_standard_stream && sst->sst_tab != NULL) in cdf_read_sector_chain()
642 return cdf_read_short_sector_chain(h, ssat, sst, sid, len, in cdf_read_sector_chain()
645 return cdf_read_long_sector_chain(info, h, sat, sid, len, scn); in cdf_read_sector_chain()
649 cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_dir() argument
653 size_t ss = CDF_SEC_SIZE(h), ns, nd; in cdf_read_dir()
655 cdf_secid_t sid = h->h_secid_first_directory; in cdf_read_dir()
679 if (cdf_read_sector(info, buf, 0, ss, h, sid) != in cdf_read_dir()
704 cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_ssat() argument
708 size_t ss = CDF_SEC_SIZE(h); in cdf_read_ssat()
709 cdf_secid_t sid = h->h_secid_first_sector_in_short_sat; in cdf_read_ssat()
731 if (cdf_read_sector(info, ssat->sat_tab, i * ss, ss, h, sid) != in cdf_read_ssat()
747 cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_short_stream() argument
773 return cdf_read_long_sector_chain(info, h, sat, in cdf_read_short_stream()
791 cdf_read_doc_summary_info(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_doc_summary_info() argument
795 return cdf_read_user_stream(info, h, sat, ssat, sst, dir, in cdf_read_doc_summary_info()
800 cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_summary_info() argument
804 return cdf_read_user_stream(info, h, sat, ssat, sst, dir, in cdf_read_summary_info()
809 cdf_read_user_stream(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_user_stream() argument
822 return cdf_read_sector_chain(info, h, sat, ssat, sst, in cdf_read_user_stream()
854 cdf_get_property_info_pos(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_get_property_info_pos() argument
865 if (cdf_check_stream_offset(sst, h, p, (tail + 1) * sizeof(uint32_t), in cdf_get_property_info_pos()
939 cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_read_property_info() argument
954 if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1) in cdf_read_property_info()
962 if (cdf_check_stream_offset(sst, h, shp, sh.sh_len, __LINE__) == -1) in cdf_read_property_info()
977 if (p >= e || cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) in cdf_read_property_info()
981 if ((q = cdf_get_property_info_pos(sst, h, p, e, i)) == NULL) in cdf_read_property_info()
1095 cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_unpack_summary_info() argument
1106 if (cdf_check_stream_offset(sst, h, si, sizeof(*si), __LINE__) == -1 || in cdf_unpack_summary_info()
1107 cdf_check_stream_offset(sst, h, sd, sizeof(*sd), __LINE__) == -1) in cdf_unpack_summary_info()
1118 if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info, in cdf_unpack_summary_info()
1134 cdf_unpack_catalog(const cdf_header_t *h, const cdf_stream_t *sst, in cdf_unpack_catalog() argument
1137 size_t ss = cdf_check_stream(sst, h); in cdf_unpack_catalog()
1295 cdf_dump_header(const cdf_header_t *h) in cdf_dump_header() argument
1299 #define DUMP(a, b) (void)fprintf(stderr, "%40.40s = " a "\n", # b, h->h_ ## b) in cdf_dump_header()
1301 h->h_ ## b, 1 << h->h_ ## b) in cdf_dump_header()
1314 for (i = 0; i < __arraycount(h->h_master_sat); i++) { in cdf_dump_header()
1315 if (h->h_master_sat[i] == CDF_SECID_FREE) in cdf_dump_header()
1318 "master_sat", i, h->h_master_sat[i]); in cdf_dump_header()
1370 cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h, in cdf_dump_dir() argument
1413 if (cdf_read_sector_chain(info, h, sat, ssat, sst, in cdf_dump_dir()
1500 cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst) in cdf_dump_summary_info() argument
1507 (void)&h; in cdf_dump_summary_info()
1508 if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1) in cdf_dump_summary_info()
1523 cdf_dump_catalog(const cdf_header_t *h, const cdf_stream_t *sst) in cdf_dump_catalog() argument
1526 cdf_unpack_catalog(h, sst, &cat); in cdf_dump_catalog()
1549 cdf_header_t h; in main() local
1570 if (cdf_read_header(&info, &h) == -1) in main()
1573 cdf_dump_header(&h); in main()
1576 if (cdf_read_sat(&info, &h, &sat) == -1) in main()
1579 cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h)); in main()
1582 if (cdf_read_ssat(&info, &h, &sat, &ssat) == -1) in main()
1585 cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h)); in main()
1588 if (cdf_read_dir(&info, &h, &sat, &dir) == -1) in main()
1591 if (cdf_read_short_stream(&info, &h, &sat, &dir, &sst, &root) in main()
1599 cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir); in main()
1603 if (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir, in main()
1608 cdf_dump_summary_info(&h, &scn); in main()
1610 if (cdf_read_user_stream(&info, &h, &sat, &ssat, &sst, in main()
1615 cdf_dump_catalog(&h, &scn); in main()