int erts_vdsprintf(erts_dsprintf_buf_t *dsbufp, const char *format, va_list arglist) { int res; if (!dsbufp) return -EINVAL; errno = 0; res = erts_printf_format(write_ds, (void *)dsbufp, (char *)format, arglist); if (dsbufp->str) { if (res < 0) dsbufp->str[0] = '\0'; else dsbufp->str[dsbufp->str_len] = '\0'; } return res; }
int erts_sprintf(char *buf, const char *format, ...) { int res; char *p = buf; va_list arglist; va_start(arglist, format); errno = 0; res = erts_printf_format(write_s, (void *) &p, (char *) format, arglist); if (res < 0) buf[0] = '\0'; else buf[res] = '\0'; va_end(arglist); return res; }
int erts_vprintf(const char *format, va_list arglist) { int res; if (erts_printf_stdout_func) res = (*erts_printf_stdout_func)((char *) format, arglist); else { errno = 0; res = erts_printf_format(erts_printf_add_cr_to_stdout ? write_f_add_cr : write_f, (void *) stdout, (char *) format, arglist); } return res; }
int erts_vsnprintf(char *buf, size_t size, const char *format, va_list arglist) { write_sn_arg_t wsnap; int res; if (size < 1) return -EINVAL; wsnap.buf = buf; wsnap.len = size-1; /* Always need room for trailing '\0' */ errno = 0; res = erts_printf_format(write_sn, (void *)&wsnap, (char *)format, arglist); if (res < 0) buf[0] = '\0'; else if (res < size) buf[res] = '\0'; else buf[size-1] = '\0'; return res; }
int erts_dsprintf(erts_dsprintf_buf_t *dsbufp, const char *format, ...) { int res; va_list arglist; if (!dsbufp) return -EINVAL; va_start(arglist, format); errno = 0; res = erts_printf_format(erts_write_ds, (void *)dsbufp, (char *)format, arglist); if (dsbufp->str) { if (res < 0) dsbufp->str[0] = '\0'; else dsbufp->str[dsbufp->str_len] = '\0'; } va_end(arglist); return res; }
int erts_vfprintf(FILE *filep, const char *format, va_list arglist) { int res; if (erts_printf_stdout_func && filep == stdout) res = (*erts_printf_stdout_func)((char *) format, arglist); else if (erts_printf_stderr_func && filep == stderr) res = (*erts_printf_stderr_func)((char *) format, arglist); else { int (*fmt_f)(void*, char*, size_t); errno = 0; if (erts_printf_add_cr_to_stdout && filep == stdout) fmt_f = write_f_add_cr; else if (erts_printf_add_cr_to_stderr && filep == stderr) fmt_f = write_f_add_cr; else fmt_f = write_f; res = erts_printf_format(fmt_f,(void *)filep,(char *)format,arglist); } return res; }
int erts_printf(const char *format, ...) { int res; va_list arglist; va_start(arglist, format); errno = 0; if (erts_printf_stdout_func) res = (*erts_printf_stdout_func)((char *) format, arglist); else { FLOCKFILE(stdout); res = erts_printf_format(erts_printf_add_cr_to_stdout ? write_f_add_cr : write_f, (void *) stdout, (char *) format, arglist); FUNLOCKFILE(stdout); } va_end(arglist); return res; }
int erts_vcbprintf(fmtfn_t cb_fn, void* cb_arg, const char *format, va_list arglist) { errno = 0; return erts_printf_format(cb_fn, cb_arg, (char *)format, arglist); }