/* A replacement for asprintf. As with the BSD of asprintf version -1 will be returned on error and NULL stored at BUFP. On success the number of bytes printed will be returned. */ int estream_asprintf (char **bufp, const char *format, ...) { int rc; va_list arg_ptr; va_start (arg_ptr, format); rc = estream_vasprintf (bufp, format, arg_ptr); va_end (arg_ptr); return rc; }
/* Variable argument version of tty_get. The prompt is is actually a format string with arguments. */ char * tty_getf (const char *promptfmt, ... ) { va_list arg_ptr; char *prompt; char *answer; va_start (arg_ptr, promptfmt); if (estream_vasprintf (&prompt, promptfmt, arg_ptr) < 0) log_fatal ("estream_vasprintf failed: %s\n", strerror (errno)); va_end (arg_ptr); answer = tty_get (prompt); xfree (prompt); return answer; }