- if (NUM_EXT_NAMES(tp)) {
- unsigned extcnt = NUM_EXT_NAMES(tp);
-
- if (even_boundary(nextfree))
- return(ERR);
-
- nextfree = compute_offsets(tp->Strings + STRCOUNT, tp->ext_Strings, offsets);
- TRACE_OUT(("after extended string capabilities, nextfree=%d", nextfree));
- nextfree += compute_offsets(tp->ext_Names, extcnt, offsets + tp->ext_Strings);
- TRACE_OUT(("after extended capnames, nextfree=%d", nextfree));
- strmax = tp->ext_Strings + extcnt;
-
- /*
- * Write the extended header
- */
- LITTLE_ENDIAN(buf+0, tp->ext_Booleans);
- LITTLE_ENDIAN(buf+2, tp->ext_Numbers);
- LITTLE_ENDIAN(buf+4, tp->ext_Strings);
- LITTLE_ENDIAN(buf+6, strmax);
- LITTLE_ENDIAN(buf+8, nextfree);
- TRACE_OUT(("WRITE extended-header @%ld", ftell(fp)));
- if (fwrite(buf, 10, 1, fp) != 1)
- return(ERR);
-
- TRACE_OUT(("WRITE %d booleans @%ld", tp->ext_Booleans, ftell(fp)));
- if (tp->ext_Booleans
- && fwrite(tp->Booleans + BOOLCOUNT, sizeof(char), tp->ext_Booleans, fp) != tp->ext_Booleans)
- return(ERR);
-
- if (even_boundary(tp->ext_Booleans))
- return(ERR);
-
- TRACE_OUT(("WRITE %d numbers @%ld", tp->ext_Numbers, ftell(fp)));
- if (tp->ext_Numbers) {
- convert_shorts(buf, tp->Numbers + NUMCOUNT, tp->ext_Numbers);
- if (fwrite(buf, 2, tp->ext_Numbers, fp) != tp->ext_Numbers)
- return(ERR);
- }