|
| iMatix home page | << | < | > | >> |
SFLVersion 2.11 |
#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.
{
va_list
argptr; /* Argument list pointer */
int
fmtsize = 0; /* Size of formatted line */
char
*formatted = NULL, /* Formatted line */
*prefixed = NULL; /* Prefixed formatted line */
if (console_active)
{
formatted = mem_alloc (LINE_MAX + 1);
if (!formatted)
return (0);
va_start (argptr, format); /* Start variable args processing */
vsnprintf (formatted, LINE_MAX, format, argptr);
va_end (argptr); /* End variable args processing */
switch (console_mode)
{
case CONSOLE_DATETIME:
xstrcpy_debug ();
prefixed = xstrcpy (NULL, date_str (), " ", time_str (), ": ",
formatted, NULL);
break;
case CONSOLE_TIME:
xstrcpy_debug ();
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, "%s", prefixed? prefixed: formatted);
fprintf (stdout, "\n");
fflush (stdout);
}
if (prefixed)
{
fmtsize = strlen (prefixed);
mem_free (prefixed);
}
else
fmtsize = strlen (formatted);
mem_free (formatted);
}
return (fmtsize);
}
| | << | < | > | >> |
|