| 382 | } |
| 383 | |
| 384 | int ply_read_header(p_ply ply) { |
| 385 | assert(ply && ply->fp && ply->io_mode == PLY_READ); |
| 386 | if (!ply_read_header_magic(ply)) return 0; |
| 387 | if (!ply_read_word(ply)) return 0; |
| 388 | /* parse file format */ |
| 389 | if (!ply_read_header_format(ply)) { |
| 390 | ply_ferror(ply, "Invalid file format"); |
| 391 | return 0; |
| 392 | } |
| 393 | /* parse elements, comments or obj_infos until the end of header */ |
| 394 | while (strcmp(BWORD(ply), "end_header")) { |
| 395 | if (!ply_read_header_comment(ply) && |
| 396 | !ply_read_header_element(ply) && |
| 397 | !ply_read_header_obj_info(ply)) { |
| 398 | ply_ferror(ply, "Unexpected token '%s'", BWORD(ply)); |
| 399 | return 0; |
| 400 | } |
| 401 | } |
| 402 | /* skip extra character? */ |
| 403 | if (ply->rn) { |
| 404 | if (BSIZE(ply) < 1 && !BREFILL(ply)) { |
| 405 | ply_ferror(ply, "Unexpected end of file"); |
| 406 | return 0; |
| 407 | } |
| 408 | BSKIP(ply, 1); |
| 409 | } |
| 410 | return 1; |
| 411 | } |
| 412 | |
| 413 | long ply_set_read_cb(p_ply ply, const char *element_name, |
| 414 | const char* property_name, p_ply_read_cb read_cb, |
no test coverage detected