Changeset aaf962e6 in mainline for uspace/lib/riff/src/chunk.c
- Timestamp:
- 2020-09-21T21:41:53Z (4 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ea459d4
- Parents:
- d145ecb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/riff/src/chunk.c
rd145ecb raaf962e6 39 39 #include <macros.h> 40 40 #include <riff/chunk.h> 41 #include <stdbool.h> 41 42 #include <stdlib.h> 42 43 … … 271 272 * @param rchunk RIFF chunk 272 273 * @param v Place to store value 273 * @return EOK on success, E IO on error.274 * @return EOK on success, ELIMIT if at the end of parent chunk, EIO on error. 274 275 */ 275 276 errno_t riff_read_uint32(riff_rchunk_t *rchunk, uint32_t *v) … … 295 296 * @param rchunk Pointer to chunk structure to fill in 296 297 * 297 * @return EOK on success, EIO on error. 298 * @return EOK on success, ELIMIT if at the end of parent chunk, 299 * EIO on error. 298 300 */ 299 301 errno_t riff_rchunk_start(riff_rchunk_t *parent, riff_rchunk_t *rchunk) … … 320 322 error: 321 323 return rc; 324 } 325 326 /** Find and start reading RIFF chunk of with specific chunk ID. 327 * Other types of chunks are skipped. 328 * 329 * @param parent Parent chunk 330 * @param rchunk Pointer to chunk structure to fill in 331 * 332 * @return EOK on success, ENOENT chunk was not found and end was reached 333 * EIO on error. 334 */ 335 errno_t riff_rchunk_match(riff_rchunk_t *parent, riff_ckid_t ckid, 336 riff_rchunk_t *rchunk) 337 { 338 errno_t rc; 339 340 while (true) { 341 rc = riff_rchunk_start(parent, rchunk); 342 if (rc == ELIMIT) 343 return ENOENT; 344 if (rc != EOK) 345 return rc; 346 347 if (rchunk->ckid == ckid) 348 break; 349 350 rc = riff_rchunk_end(rchunk); 351 if (rc != EOK) 352 return rc; 353 } 354 355 return EOK; 356 } 357 358 /** Find and start reading RIFF LIST chunk of specified type. 359 * Other chunks or LIST chunks of other type are skipped. 360 * 361 * @param parent Parent chunk 362 * @param rchunk Pointer to chunk structure to fill in 363 * 364 * @return EOK on success, ENOENT chunk was not found and end was reached 365 * EIO on error. 366 */ 367 errno_t riff_rchunk_list_match(riff_rchunk_t *parent, riff_ltype_t ltype, 368 riff_rchunk_t *rchunk) 369 { 370 errno_t rc; 371 riff_ltype_t rltype; 372 373 while (true) { 374 rc = riff_rchunk_match(parent, CKID_LIST, rchunk); 375 if (rc == ELIMIT) 376 return ENOENT; 377 if (rc != EOK) 378 return rc; 379 380 rc = riff_read_uint32(parent, &rltype); 381 if (rc != EOK) 382 return rc; 383 384 if (rltype == ltype) 385 break; 386 387 rc = riff_rchunk_end(rchunk); 388 if (rc != EOK) 389 return rc; 390 } 391 392 return EOK; 322 393 } 323 394
Note:
See TracChangeset
for help on using the changeset viewer.