MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / gzvprintf

Function gzvprintf

extlibs/minizip/src/gzwrite.c:418–490  ·  view source on GitHub ↗

-- see zlib.h -- */

Source from the content-addressed store, hash-verified

416
417/* -- see zlib.h -- */
418int ZEXPORTVA gzvprintf(gzFile file, const char* format, va_list va)
419{
420 int len;
421 unsigned left;
422 char* next;
423 gz_statep state;
424 z_streamp strm;
425
426 /* get internal structure */
427 if (file == NULL)
428 return Z_STREAM_ERROR;
429 state = (gz_statep)file;
430 strm = &(state->strm);
431
432 /* check that we're writing and that there's no error */
433 if (state->mode != GZ_WRITE || state->err != Z_OK)
434 return Z_STREAM_ERROR;
435
436 /* make sure we have some buffer space */
437 if (state->size == 0 && gz_init(state) == -1)
438 return state->err;
439
440 /* check for seek request */
441 if (state->seek)
442 {
443 state->seek = 0;
444 if (gz_zero(state, state->skip) == -1)
445 return state->err;
446 }
447
448 /* do the printf() into the input buffer, put length in len -- the input
449 buffer is double-sized just for this function, so there is guaranteed to
450 be state->size bytes available after the current contents */
451 if (strm->avail_in == 0)
452 strm->next_in = state->in;
453 next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
454 next[state->size - 1] = 0;
455#ifdef NO_vsnprintf
456# ifdef HAS_vsprintf_void
457 (void)vsprintf(next, format, va);
458 for (len = 0; len < state->size; len++)
459 if (next[len] == 0) break;
460# else
461 len = vsprintf(next, format, va);
462# endif
463#else
464# ifdef HAS_vsnprintf_void
465 (void)vsnprintf(next, state->size, format, va);
466 len = strlen(next);
467# else
468 len = vsnprintf(next, state->size, format, va);
469# endif
470#endif
471
472 /* check that printf() results fit in buffer */
473 if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
474 return 0;
475

Callers 1

gzprintfFunction · 0.85

Calls 4

gz_initFunction · 0.85
gz_zeroFunction · 0.85
vsprintfFunction · 0.85
gz_compFunction · 0.85

Tested by

no test coverage detected