MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ZEXPORTVA

Function ZEXPORTVA

freebsd/contrib/zstd/zlibWrapper/gzwrite.c:471–554  ·  view source on GitHub ↗

-- 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)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 6

sprintfFunction · 0.85
snprintfFunction · 0.85
gz_initFunction · 0.70
gz_zeroFunction · 0.70
gz_compFunction · 0.70
memcpyFunction · 0.50

Tested by

no test coverage detected