| 614 | } |
| 615 | |
| 616 | int ply_write(p_ply ply, double value) { |
| 617 | p_ply_element element = NULL; |
| 618 | p_ply_property property = NULL; |
| 619 | int type = -1; |
| 620 | int breakafter = 0; |
| 621 | int spaceafter = 1; |
| 622 | if (ply->welement > ply->nelements) return 0; |
| 623 | element = &ply->element[ply->welement]; |
| 624 | if (ply->wproperty > element->nproperties) return 0; |
| 625 | property = &element->property[ply->wproperty]; |
| 626 | if (property->type == PLY_LIST) { |
| 627 | if (ply->wvalue_index == 0) { |
| 628 | type = property->length_type; |
| 629 | ply->wlength = (long) value; |
| 630 | } else type = property->value_type; |
| 631 | } else { |
| 632 | type = property->type; |
| 633 | ply->wlength = 0; |
| 634 | } |
| 635 | if (!ply->odriver->ohandler[type](ply, value)) { |
| 636 | ply_ferror(ply, "Failed writing %s of %s %d (%s: %s)", |
| 637 | property->name, element->name, |
| 638 | ply->winstance_index, |
| 639 | ply->odriver->name, ply_type_list[type]); |
| 640 | return 0; |
| 641 | } |
| 642 | ply->wvalue_index++; |
| 643 | if (ply->wvalue_index > ply->wlength) { |
| 644 | ply->wvalue_index = 0; |
| 645 | ply->wproperty++; |
| 646 | } |
| 647 | if (ply->wproperty >= element->nproperties) { |
| 648 | ply->wproperty = 0; |
| 649 | ply->winstance_index++; |
| 650 | breakafter = 1; |
| 651 | spaceafter = 0; |
| 652 | } |
| 653 | if (ply->winstance_index >= element->ninstances) { |
| 654 | ply->winstance_index = 0; |
| 655 | do { |
| 656 | ply->welement++; |
| 657 | element = &ply->element[ply->welement]; |
| 658 | } while (ply->welement < ply->nelements && !element->ninstances); |
| 659 | } |
| 660 | if (ply->storage_mode == PLY_ASCII) { |
| 661 | return (!spaceafter || putc(' ', ply->fp) > 0) && |
| 662 | (!breakafter || putc('\n', ply->fp) > 0); |
| 663 | } else { |
| 664 | return 1; |
| 665 | } |
| 666 | } |
| 667 | |
| 668 | int ply_close(p_ply ply) { |
| 669 | long i; |
no test coverage detected