示例#1
0
文件: debug.c 项目: ActionLuzifer/mc
/* ************************************************************************** **
 * Format the debug message text.
 *
 *  Input:  msg - Text to be added to the "current" debug message text.
 *
 *  Output: none.
 *
 *  Notes:  The purpose of this is two-fold.  First, each call to syslog()
 *          (used by Debug1(), see above) generates a new line of syslog
 *          output.  This is fixed by storing the partial lines until the
 *          newline character is encountered.  Second, printing the debug
 *          message lines when a newline is encountered allows us to add
 *          spaces, thus indenting the body of the message and making it
 *          more readable.
 *
 * ************************************************************************** **
 */
static void
format_debug_text (char *msg)
{
    size_t i;
    BOOL timestamp = (!stdout_logging && (lp_timestamp_logs () || !(lp_loaded ())));

    for (i = 0; msg[i]; i++)
    {
        /* Indent two spaces at each new line. */
        if (timestamp && 0 == format_pos)
        {
            format_bufr[0] = format_bufr[1] = ' ';
            format_pos = 2;
        }

        /* If there's room, copy the character to the format buffer. */
        if (format_pos < FORMAT_BUFR_MAX)
            format_bufr[format_pos++] = msg[i];

        /* If a newline is encountered, print & restart. */
        if ('\n' == msg[i])
            bufr_print ();

        /* If the buffer is full dump it out, reset it, and put out a line
         * continuation indicator.
         */
        if (format_pos >= FORMAT_BUFR_MAX)
        {
            bufr_print ();
            (void) Debug1 (" +>\n");
        }
    }

    /* Just to be safe... */
    format_bufr[format_pos] = '\0';
}                               /* format_debug_text */
示例#2
0
文件: debug.c 项目: ActionLuzifer/mc
/* ************************************************************************** **
 * Flush debug output, including the format buffer content.
 *
 *  Input:  none
 *  Output: none
 *
 * ************************************************************************** **
 */
void
dbgflush (void)
{
    bufr_print ();
    (void) fflush (dbf);
}                               /* dbgflush */
示例#3
0
文件: debug.c 项目: hynnet/ralink_sdk
/* ************************************************************************** **
 * Flush debug output, including the format buffer content.
 *
 *  Input:  none
 *  Output: none
 *
 * ************************************************************************** **
 */
void dbgflush( void )
{
    bufr_print();
    if(dbf)
        (void)x_fflush( dbf );
} /* dbgflush */