| 269 | } |
| 270 | |
| 271 | static int |
| 272 | _vprintf(int level, int flags, const char *fmt, va_list ap) |
| 273 | { |
| 274 | struct putchar_arg pca; |
| 275 | int retval; |
| 276 | #ifdef PRINTF_BUFR_SIZE |
| 277 | char bufr[PRINTF_BUFR_SIZE]; |
| 278 | #endif |
| 279 | |
| 280 | TSENTER(); |
| 281 | pca.tty = NULL; |
| 282 | pca.pri = level; |
| 283 | pca.flags = flags; |
| 284 | #ifdef PRINTF_BUFR_SIZE |
| 285 | pca.p_bufr = bufr; |
| 286 | pca.p_next = pca.p_bufr; |
| 287 | pca.n_bufr = sizeof(bufr); |
| 288 | pca.remain = sizeof(bufr); |
| 289 | *pca.p_next = '\0'; |
| 290 | #else |
| 291 | /* Don't buffer console output. */ |
| 292 | pca.p_bufr = NULL; |
| 293 | #endif |
| 294 | |
| 295 | retval = kvprintf(fmt, putchar, &pca, 10, ap); |
| 296 | |
| 297 | #ifdef PRINTF_BUFR_SIZE |
| 298 | /* Write any buffered console/log output: */ |
| 299 | if (*pca.p_bufr != '\0') { |
| 300 | if (pca.flags & TOLOG) |
| 301 | msglogstr(pca.p_bufr, level, /*filter_cr*/1); |
| 302 | |
| 303 | if (pca.flags & TOCONS) |
| 304 | cnputs(pca.p_bufr); |
| 305 | } |
| 306 | #endif |
| 307 | |
| 308 | TSEXIT(); |
| 309 | return (retval); |
| 310 | } |
| 311 | |
| 312 | /* |
| 313 | * Log writes to the log buffer, and guarantees not to sleep (so can be |