Lines Matching refs:h

175 cdf_swap_header(cdf_header_t *h)  in cdf_swap_header()  argument
179 h->h_magic = CDF_TOLE8(h->h_magic); in cdf_swap_header()
180 h->h_uuid[0] = CDF_TOLE8(h->h_uuid[0]); in cdf_swap_header()
181 h->h_uuid[1] = CDF_TOLE8(h->h_uuid[1]); in cdf_swap_header()
182 h->h_revision = CDF_TOLE2(h->h_revision); in cdf_swap_header()
183 h->h_version = CDF_TOLE2(h->h_version); in cdf_swap_header()
184 h->h_byte_order = CDF_TOLE2(h->h_byte_order); in cdf_swap_header()
185 h->h_sec_size_p2 = CDF_TOLE2(h->h_sec_size_p2); in cdf_swap_header()
186 h->h_short_sec_size_p2 = CDF_TOLE2(h->h_short_sec_size_p2); in cdf_swap_header()
187 h->h_num_sectors_in_sat = CDF_TOLE4(h->h_num_sectors_in_sat); in cdf_swap_header()
188 h->h_secid_first_directory = CDF_TOLE4(h->h_secid_first_directory); in cdf_swap_header()
189 h->h_min_size_standard_stream = in cdf_swap_header()
190 CDF_TOLE4(h->h_min_size_standard_stream); in cdf_swap_header()
191 h->h_secid_first_sector_in_short_sat = in cdf_swap_header()
192 CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_short_sat); in cdf_swap_header()
193 h->h_num_sectors_in_short_sat = in cdf_swap_header()
194 CDF_TOLE4(h->h_num_sectors_in_short_sat); in cdf_swap_header()
195 h->h_secid_first_sector_in_master_sat = in cdf_swap_header()
196 CDF_TOLE4((uint32_t)h->h_secid_first_sector_in_master_sat); in cdf_swap_header()
197 h->h_num_sectors_in_master_sat = in cdf_swap_header()
198 CDF_TOLE4(h->h_num_sectors_in_master_sat); in cdf_swap_header()
199 for (i = 0; i < __arraycount(h->h_master_sat); i++) in cdf_swap_header()
200 h->h_master_sat[i] = CDF_TOLE4((uint32_t)h->h_master_sat[i]); in cdf_swap_header()
204 cdf_unpack_header(cdf_header_t *h, char *buf) in cdf_unpack_header() argument
209 CDF_UNPACK(h->h_magic); in cdf_unpack_header()
210 CDF_UNPACKA(h->h_uuid); in cdf_unpack_header()
211 CDF_UNPACK(h->h_revision); in cdf_unpack_header()
212 CDF_UNPACK(h->h_version); in cdf_unpack_header()
213 CDF_UNPACK(h->h_byte_order); in cdf_unpack_header()
214 CDF_UNPACK(h->h_sec_size_p2); in cdf_unpack_header()
215 CDF_UNPACK(h->h_short_sec_size_p2); in cdf_unpack_header()
216 CDF_UNPACKA(h->h_unused0); in cdf_unpack_header()
217 CDF_UNPACK(h->h_num_sectors_in_sat); in cdf_unpack_header()
218 CDF_UNPACK(h->h_secid_first_directory); in cdf_unpack_header()
219 CDF_UNPACKA(h->h_unused1); in cdf_unpack_header()
220 CDF_UNPACK(h->h_min_size_standard_stream); in cdf_unpack_header()
221 CDF_UNPACK(h->h_secid_first_sector_in_short_sat); in cdf_unpack_header()
222 CDF_UNPACK(h->h_num_sectors_in_short_sat); in cdf_unpack_header()
223 CDF_UNPACK(h->h_secid_first_sector_in_master_sat); in cdf_unpack_header()
224 CDF_UNPACK(h->h_num_sectors_in_master_sat); in cdf_unpack_header()
225 for (i = 0; i < __arraycount(h->h_master_sat); i++) in cdf_unpack_header()
226 CDF_UNPACK(h->h_master_sat[i]); in cdf_unpack_header()
275 cdf_check_stream_offset(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_check_stream_offset() argument
280 size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ? in cdf_check_stream_offset()
281 CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h); in cdf_check_stream_offset()
321 cdf_read_header(const cdf_info_t *info, cdf_header_t *h) in cdf_read_header() argument
328 cdf_unpack_header(h, buf); in cdf_read_header()
329 cdf_swap_header(h); in cdf_read_header()
330 if (h->h_magic != CDF_MAGIC) { in cdf_read_header()
333 (unsigned long long)h->h_magic, in cdf_read_header()
337 if (h->h_sec_size_p2 > 20) { in cdf_read_header()
338 DPRINTF(("Bad sector size 0x%u\n", h->h_sec_size_p2)); in cdf_read_header()
341 if (h->h_short_sec_size_p2 > 20) { in cdf_read_header()
343 h->h_short_sec_size_p2)); in cdf_read_header()
355 const cdf_header_t *h, cdf_secid_t id) in cdf_read_sector() argument
357 size_t ss = CDF_SEC_SIZE(h); in cdf_read_sector()
358 size_t pos = CDF_SEC_POS(h, id); in cdf_read_sector()
365 size_t len, const cdf_header_t *h, cdf_secid_t id) in cdf_read_short_sector() argument
367 size_t ss = CDF_SHORT_SEC_SIZE(h); in cdf_read_short_sector()
368 size_t pos = CDF_SHORT_SEC_POS(h, id); in cdf_read_short_sector()
370 if (pos + len > CDF_SEC_SIZE(h) * sst->sst_len) { in cdf_read_short_sector()
373 pos + len, CDF_SEC_SIZE(h) * sst->sst_len)); in cdf_read_short_sector()
385 cdf_read_sat(const cdf_info_t *info, cdf_header_t *h, cdf_sat_t *sat) in cdf_read_sat() argument
388 size_t ss = CDF_SEC_SIZE(h); in cdf_read_sat()
392 for (i = 0; i < __arraycount(h->h_master_sat); i++) in cdf_read_sat()
393 if (h->h_master_sat[i] == CDF_SECID_FREE) in cdf_read_sat()
398 h->h_num_sectors_in_master_sat > CDF_SEC_LIMIT / nsatpersec) || in cdf_read_sat()
401 SIZE_T_FORMAT "u\n", h->h_num_sectors_in_master_sat, i)); in cdf_read_sat()
406 sat->sat_len = h->h_num_sectors_in_master_sat * nsatpersec + i; in cdf_read_sat()
413 for (i = 0; i < __arraycount(h->h_master_sat); i++) { in cdf_read_sat()
414 if (h->h_master_sat[i] < 0) in cdf_read_sat()
416 if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h, in cdf_read_sat()
417 h->h_master_sat[i]) != (ssize_t)ss) { in cdf_read_sat()
418 DPRINTF(("Reading sector %d", h->h_master_sat[i])); in cdf_read_sat()
426 mid = h->h_secid_first_sector_in_master_sat; in cdf_read_sat()
427 for (j = 0; j < h->h_num_sectors_in_master_sat; j++) { in cdf_read_sat()
435 if (cdf_read_sector(info, msa, 0, ss, h, mid) != (ssize_t)ss) { in cdf_read_sat()
449 if (cdf_read_sector(info, sat->sat_tab, ss * i, ss, h, in cdf_read_sat()
496 cdf_read_long_sector_chain(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_long_sector_chain() argument
499 size_t ss = CDF_SEC_SIZE(h), i, j; in cdf_read_long_sector_chain()
524 if ((nr = cdf_read_sector(info, scn->sst_tab, i * ss, ss, h, in cdf_read_long_sector_chain()
542 cdf_read_short_sector_chain(const cdf_header_t *h, in cdf_read_short_sector_chain() argument
546 size_t ss = CDF_SHORT_SEC_SIZE(h), i, j; in cdf_read_short_sector_chain()
547 scn->sst_len = cdf_count_chain(ssat, sid, CDF_SEC_SIZE(h)); in cdf_read_short_sector_chain()
570 if (cdf_read_short_sector(sst, scn->sst_tab, i * ss, ss, h, in cdf_read_short_sector_chain()
584 cdf_read_sector_chain(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_sector_chain() argument
589 if (len < h->h_min_size_standard_stream && sst->sst_tab != NULL) in cdf_read_sector_chain()
590 return cdf_read_short_sector_chain(h, ssat, sst, sid, len, in cdf_read_sector_chain()
593 return cdf_read_long_sector_chain(info, h, sat, sid, len, scn); in cdf_read_sector_chain()
597 cdf_read_dir(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_dir() argument
601 size_t ss = CDF_SEC_SIZE(h), ns, nd; in cdf_read_dir()
603 cdf_secid_t sid = h->h_secid_first_directory; in cdf_read_dir()
628 if (cdf_read_sector(info, buf, 0, ss, h, sid) != (ssize_t)ss) { in cdf_read_dir()
651 cdf_read_ssat(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_ssat() argument
655 size_t ss = CDF_SEC_SIZE(h); in cdf_read_ssat()
656 cdf_secid_t sid = h->h_secid_first_sector_in_short_sat; in cdf_read_ssat()
658 ssat->sat_len = cdf_count_chain(sat, sid, CDF_SEC_SIZE(h)); in cdf_read_ssat()
679 if (cdf_read_sector(info, ssat->sat_tab, i * ss, ss, h, sid) != in cdf_read_ssat()
693 cdf_read_short_stream(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_short_stream() argument
712 return cdf_read_long_sector_chain(info, h, sat, in cdf_read_short_stream()
731 cdf_read_summary_info(const cdf_info_t *info, const cdf_header_t *h, in cdf_read_summary_info() argument
751 return cdf_read_sector_chain(info, h, sat, ssat, sst, in cdf_read_summary_info()
756 cdf_read_property_info(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_read_property_info() argument
777 if (cdf_check_stream_offset(sst, h, shp, sizeof(*shp), __LINE__) == -1) in cdf_read_property_info()
812 if (cdf_check_stream_offset(sst, h, e, 0, __LINE__) == -1) in cdf_read_property_info()
816 if (cdf_check_stream_offset(sst, h, p, tail * sizeof(uint32_t), in cdf_read_property_info()
955 cdf_unpack_summary_info(const cdf_stream_t *sst, const cdf_header_t *h, in cdf_unpack_summary_info() argument
965 if (cdf_check_stream_offset(sst, h, si, sizeof(*si), __LINE__) == -1 || in cdf_unpack_summary_info()
966 cdf_check_stream_offset(sst, h, sd, sizeof(*sd), __LINE__) == -1) in cdf_unpack_summary_info()
977 if (cdf_read_property_info(sst, h, CDF_TOLE4(sd->sd_offset), info, in cdf_unpack_summary_info()
1070 cdf_dump_header(const cdf_header_t *h) in cdf_dump_header() argument
1074 #define DUMP(a, b) (void)fprintf(stderr, "%40.40s = " a "\n", # b, h->h_ ## b) in cdf_dump_header()
1076 h->h_ ## b, 1 << h->h_ ## b) in cdf_dump_header()
1089 for (i = 0; i < __arraycount(h->h_master_sat); i++) { in cdf_dump_header()
1090 if (h->h_master_sat[i] == CDF_SECID_FREE) in cdf_dump_header()
1093 "master_sat", i, h->h_master_sat[i]); in cdf_dump_header()
1137 cdf_dump_stream(const cdf_header_t *h, const cdf_stream_t *sst) in cdf_dump_stream() argument
1139 size_t ss = sst->sst_dirlen < h->h_min_size_standard_stream ? in cdf_dump_stream()
1140 CDF_SHORT_SEC_SIZE(h) : CDF_SEC_SIZE(h); in cdf_dump_stream()
1145 cdf_dump_dir(const cdf_info_t *info, const cdf_header_t *h, in cdf_dump_dir() argument
1186 if (cdf_read_sector_chain(info, h, sat, ssat, sst, in cdf_dump_dir()
1192 cdf_dump_stream(h, &scn); in cdf_dump_dir()
1276 cdf_dump_summary_info(const cdf_header_t *h, const cdf_stream_t *sst) argument
1283 (void)&h;
1284 if (cdf_unpack_summary_info(sst, h, &ssi, &info, &count) == -1)
1304 cdf_header_t h; local
1321 if (cdf_read_header(&info, &h) == -1)
1324 cdf_dump_header(&h);
1327 if (cdf_read_sat(&info, &h, &sat) == -1)
1330 cdf_dump_sat("SAT", &sat, CDF_SEC_SIZE(&h));
1333 if (cdf_read_ssat(&info, &h, &sat, &ssat) == -1)
1336 cdf_dump_sat("SSAT", &ssat, CDF_SHORT_SEC_SIZE(&h));
1339 if (cdf_read_dir(&info, &h, &sat, &dir) == -1)
1342 if (cdf_read_short_stream(&info, &h, &sat, &dir, &sst) == -1)
1345 cdf_dump_stream(&h, &sst);
1349 cdf_dump_dir(&info, &h, &sat, &ssat, &sst, &dir);
1353 if (cdf_read_summary_info(&info, &h, &sat, &ssat, &sst, &dir,
1357 cdf_dump_summary_info(&h, &scn);