save one object; caveat: this is only for update_file(); caller handles release_data() */
| 723 | /* save one object; |
| 724 | caveat: this is only for update_file(); caller handles release_data() */ |
| 725 | staticfn void |
| 726 | saveobj(NHFILE *nhfp, struct obj *otmp) |
| 727 | { |
| 728 | int buflen, zerobuf = 0; |
| 729 | |
| 730 | buflen = (int) sizeof (struct obj); |
| 731 | Sfo_int(nhfp, &buflen, "obj-obj_length"); |
| 732 | Sfo_obj(nhfp, otmp, "obj"); |
| 733 | if (otmp->oextra) { |
| 734 | buflen = ONAME(otmp) ? (int) strlen(ONAME(otmp)) + 1 : 0; |
| 735 | Sfo_int(nhfp, &buflen, "obj-oname_length"); |
| 736 | |
| 737 | if (buflen > 0) { |
| 738 | Sfo_char(nhfp, ONAME(otmp), "obj-oname", buflen); |
| 739 | } |
| 740 | /* defer to savemon() for this one */ |
| 741 | if (OMONST(otmp)) { |
| 742 | savemon(nhfp, OMONST(otmp)); |
| 743 | } else { |
| 744 | Sfo_int(nhfp, &zerobuf, "obj-omonst_length"); |
| 745 | } |
| 746 | /* extra info about scroll of mail */ |
| 747 | buflen = OMAILCMD(otmp) ? (int) strlen(OMAILCMD(otmp)) + 1 : 0; |
| 748 | Sfo_int(nhfp, &buflen, "obj-omailcmd_length"); |
| 749 | if (buflen > 0) { |
| 750 | Sfo_char(nhfp, OMAILCMD(otmp), "obj-omailcmd", buflen); |
| 751 | } |
| 752 | /* omid used to be indirect via a pointer in oextra but has |
| 753 | become part of oextra itself; 0 means not applicable and |
| 754 | gets saved/restored whenever any other oextra components do */ |
| 755 | Sfo_unsigned(nhfp, &OMID(otmp), "obj-omid"); |
| 756 | } |
| 757 | } |
| 758 | |
| 759 | /* save an object chain; sets head of list to Null when done; |
| 760 | handles release_data() for each object in the list */ |