-- see zlib.h -- */
(file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10,
a11, a12, a13, a14, a15, a16, a17, a18, a19, a20)
| 466 | |
| 467 | /* -- see zlib.h -- */ |
| 468 | int ZEXPORTVA gzprintf (file, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
| 469 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20) |
| 470 | gzFile file; |
| 471 | const char *format; |
| 472 | int a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, |
| 473 | a11, a12, a13, a14, a15, a16, a17, a18, a19, a20; |
| 474 | { |
| 475 | unsigned len, left; |
| 476 | char *next; |
| 477 | gz_statep state; |
| 478 | z_streamp strm; |
| 479 | |
| 480 | /* get internal structure */ |
| 481 | if (file == NULL) |
| 482 | return Z_STREAM_ERROR; |
| 483 | state = (gz_statep)file; |
| 484 | strm = &(state->strm); |
| 485 | |
| 486 | /* check that can really pass pointer in ints */ |
| 487 | if (sizeof(int) != sizeof(void *)) |
| 488 | return Z_STREAM_ERROR; |
| 489 | |
| 490 | /* check that we're writing and that there's no error */ |
| 491 | if (state->mode != GZ_WRITE || state->err != Z_OK) |
| 492 | return Z_STREAM_ERROR; |
| 493 | |
| 494 | /* make sure we have some buffer space */ |
| 495 | if (state->size == 0 && gz_init(state) == -1) |
| 496 | return state->error; |
| 497 | |
| 498 | /* check for seek request */ |
| 499 | if (state->seek) { |
| 500 | state->seek = 0; |
| 501 | if (gz_zero(state, state->skip) == -1) |
| 502 | return state->error; |
| 503 | } |
| 504 | |
| 505 | /* do the printf() into the input buffer, put length in len -- the input |
| 506 | buffer is double-sized just for this function, so there is guaranteed to |
| 507 | be state->size bytes available after the current contents */ |
| 508 | if (strm->avail_in == 0) |
| 509 | strm->next_in = state->in; |
| 510 | next = (char *)(strm->next_in + strm->avail_in); |
| 511 | next[state->size - 1] = 0; |
| 512 | #ifdef NO_snprintf |
| 513 | # ifdef HAS_sprintf_void |
| 514 | sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12, |
| 515 | a13, a14, a15, a16, a17, a18, a19, a20); |
| 516 | for (len = 0; len < size; len++) |
| 517 | if (next[len] == 0) |
| 518 | break; |
| 519 | # else |
| 520 | len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, |
| 521 | a12, a13, a14, a15, a16, a17, a18, a19, a20); |
| 522 | # endif |
| 523 | #else |
| 524 | # ifdef HAS_snprintf_void |
| 525 | snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, |