| iMatix home page | << | < | > | >> |
![]() Version 1.91 |
#include "sflcons.h" int coprintf (const char *format, ...)
As printf() but sends output to the current console. This is by default the stdout device, unless you used console send() to direct console output to some function. A newline is added automatically.
{ static char formatted [LINE_MAX]; va_list argptr; /* Argument list pointer */ int fmtsize = 0; /* Size of formatted line */ char *prefixed = NULL; /* Prefixed formatted line */ if (console_active) { va_start (argptr, format); /* Start variable args processing */ #if (defined (DOES_SNPRINTF)) fmtsize = vsnprintf (formatted, LINE_MAX, format, argptr); #else fmtsize = vsprintf (formatted, format, argptr); #endif va_end (argptr); /* End variable args processing */ ASSERT (fmtsize < LINE_MAX); switch (console_mode) { case CONSOLE_DATETIME: prefixed = xstrcpy (NULL, date_str (), " ", time_str (), ": ", formatted, NULL); break; case CONSOLE_TIME: prefixed = xstrcpy (NULL, time_str (), ": ", formatted, NULL); break; } if (console_file) { file write (console_file, prefixed? prefixed: formatted); fflush (console_file); } if (console_fct) (console_fct) (prefixed? prefixed: formatted); if (console_echo) { fprintf (stdout, prefixed? prefixed: formatted); fprintf (stdout, "\n"); fflush (stdout); } if (prefixed) { fmtsize = strlen (prefixed); mem_free (prefixed); } } return (fmtsize); }
| << | < | > | >> |
![]() |