openbmc/build/tmp/deploy/sdk/witherspoon-2019-08-08/sysroots/armv6-openbmc-linux-gnueabi/usr/src/debug/rsyslog/8.1903.0-r0/rsyslog-8.1903.0/tools/rsyslogd.c
rsRetVal logmsgInternal(int iErr, const syslog_pri_t pri,
                        const uchar* const msg, int flags)
{
    size_t lenMsg;
    unsigned i;
    char* bufModMsg =
        NULL; /* buffer for modified message, should we need to modify */
    DEFiRet;

    /* we first do a path the remove control characters that may have accidently
     * introduced (program error!). This costs performance, but we do not expect
     * to be called very frequently in any case ;) -- rgerhards, 2013-12-19.
     */
    lenMsg = ustrlen(msg);
    for (i = 0; i < lenMsg; ++i)
    {
        if (msg[i] < 0x20 || msg[i] == 0x7f)
        {
            if (bufModMsg == NULL)
            {
                CHKmalloc(bufModMsg = strdup((char*)msg));
            }
            bufModMsg[i] = ' ';
        }
    }

    CHKiRet(logmsgInternalSubmit(iErr, pri, lenMsg,
                                 (bufModMsg == NULL) ? (char*)msg : bufModMsg,
                                 flags));

    /* we now check if we should print internal messages out to stderr. This was
     * suggested by HKS as a way to help people troubleshoot rsyslog
     * configuration (by running it interactively. This makes an awful lot of
     * sense, so I add it here. -- rgerhards, 2008-07-28 Note that error
     * messages can not be disabled during a config verify. This permits us to
     * process unmodified config files which otherwise contain a supressor
     * statement.
     */
    int emit_to_stderr =
        (ourConf == NULL) ? 1 : ourConf->globals.bErrMsgToStderr;
    int emit_supress_msg = 0;
    if (Debug == DEBUG_FULL || !doFork)
    {
        emit_to_stderr = 1;
    }
    if (ourConf != NULL && ourConf->globals.maxErrMsgToStderr != -1)
    {
        if (emit_to_stderr && ourConf->globals.maxErrMsgToStderr != -1 &&
            ourConf->globals.maxErrMsgToStderr)
        {
            --ourConf->globals.maxErrMsgToStderr;
            if (ourConf->globals.maxErrMsgToStderr == 0)
                emit_supress_msg = 1;
        }
        else
        {
            emit_to_stderr = 0;
        }
    }
    if (emit_to_stderr || iConfigVerify)
    {
        if (pri2sev(pri) == LOG_ERR)
            fprintf(stderr, "rsyslogd: %s\n",
                    (bufModMsg == NULL) ? (char*)msg : bufModMsg);
    }
    if (emit_supress_msg)
    {
        fprintf(stderr,
                "rsyslogd: configured max number of error messages "
                "to stderr reached, further messages will not be output\n"
                "Consider adjusting\n"
                "    global(errorMessagesToStderr.maxNumber=\"xx\")\n"
                "if you want more.\n");
    }

finalize_it:
    free(bufModMsg);
    RETiRet;
}
/* rgerhards 2004-11-09: the following is a function that can be used
 * to log a message orginating from the syslogd itself.
 */
rgerhards 2004-11-09: the following is a function that can be used
to log a message orginating from the syslogd itself.
rgerhards 2004 - 11 - 09 : the following is a function that can be used to log a message orginating from the syslogd itself .
rsRetVal logmsgInternal(int iErr, const syslog_pri_t pri,
                        const uchar* const msg, int flags)
{
    size_t lenMsg;
    unsigned i;
    char* bufModMsg =
        NULL; 
    DEFiRet;
    lenMsg = ustrlen(msg);
    for (i = 0; i < lenMsg; ++i)
    {
        if (msg[i] < 0x20 || msg[i] == 0x7f)
        {
            if (bufModMsg == NULL)
            {
                CHKmalloc(bufModMsg = strdup((char*)msg));
            }
            bufModMsg[i] = ' ';
        }
    }
    CHKiRet(logmsgInternalSubmit(iErr, pri, lenMsg,
                                 (bufModMsg == NULL) ? (char*)msg : bufModMsg,
                                 flags));
    int emit_to_stderr =
        (ourConf == NULL) ? 1 : ourConf->globals.bErrMsgToStderr;
    int emit_supress_msg = 0;
    if (Debug == DEBUG_FULL || !doFork)
    {
        emit_to_stderr = 1;
    }
    if (ourConf != NULL && ourConf->globals.maxErrMsgToStderr != -1)
    {
        if (emit_to_stderr && ourConf->globals.maxErrMsgToStderr != -1 &&
            ourConf->globals.maxErrMsgToStderr)
        {
            --ourConf->globals.maxErrMsgToStderr;
            if (ourConf->globals.maxErrMsgToStderr == 0)
                emit_supress_msg = 1;
        }
        else
        {
            emit_to_stderr = 0;
        }
    }
    if (emit_to_stderr || iConfigVerify)
    {
        if (pri2sev(pri) == LOG_ERR)
            fprintf(stderr, "rsyslogd: %s\n",
                    (bufModMsg == NULL) ? (char*)msg : bufModMsg);
    }
    if (emit_supress_msg)
    {
        fprintf(stderr,
                "rsyslogd: configured max number of error messages "
                "to stderr reached, further messages will not be output\n"
                "Consider adjusting\n"
                "    global(errorMessagesToStderr.maxNumber=\"xx\")\n"
                "if you want more.\n");
    }
finalize_it:
    free(bufModMsg);
    RETiRet;
}
rsRetVal logmsgInternal ( int iErr , const syslog_pri_t pri , const uchar * const msg , int flags ) { size_t lenMsg ; unsigned i ; char * bufModMsg = NULL ; DEFiRet ; lenMsg = ustrlen ( msg ) ; for ( i = 0 ; i < lenMsg ; ++ i ) { if ( msg [ i ] < 0x20 || msg [ i ] == 0x7f ) { if ( bufModMsg == NULL ) { CHKmalloc ( bufModMsg = strdup ( ( char * ) msg ) ) ; } bufModMsg [ i ] = ' ' ; } } CHKiRet ( logmsgInternalSubmit ( iErr , pri , lenMsg , ( bufModMsg == NULL ) ? ( char * ) msg : bufModMsg , flags ) ) ; int emit_to_stderr = ( ourConf == NULL ) ? 1 : ourConf -> globals . bErrMsgToStderr ; int emit_supress_msg = 0 ; if ( Debug == DEBUG_FULL || ! doFork ) { emit_to_stderr = 1 ; } if ( ourConf != NULL && ourConf -> globals . maxErrMsgToStderr != -1 ) { if ( emit_to_stderr && ourConf -> globals . maxErrMsgToStderr != -1 && ourConf -> globals . maxErrMsgToStderr ) { -- ourConf -> globals . maxErrMsgToStderr ; if ( ourConf -> globals . maxErrMsgToStderr == 0 ) emit_supress_msg = 1 ; } else { emit_to_stderr = 0 ; } } if ( emit_to_stderr || iConfigVerify ) { if ( pri2sev ( pri ) == LOG_ERR ) fprintf ( stderr , " \n " , ( bufModMsg == NULL ) ? ( char * ) msg : bufModMsg ) ; } if ( emit_supress_msg ) { fprintf ( stderr , " " " \n " " \n " " \" \" \n " " \n " ) ; } finalize_it : free ( bufModMsg ) ; RETiRet ; }
rgerhards 2004-11-09: the following is a function that can be used
 to log a message orginating from the syslogd itself.
rgerhards 2004 - 11 - 09 : the following is a function that can be used to log a message orginating from the syslogd itself .
/* buffer for modified message, should we need to modify */ /* we first do a path the remove control characters that may have accidently
     * introduced (program error!). This costs performance, but we do not expect
     * to be called very frequently in any case ;) -- rgerhards, 2013-12-19.
     */ /* we now check if we should print internal messages out to stderr. This was
     * suggested by HKS as a way to help people troubleshoot rsyslog
     * configuration (by running it interactively. This makes an awful lot of
     * sense, so I add it here. -- rgerhards, 2008-07-28 Note that error
     * messages can not be disabled during a config verify. This permits us to
     * process unmodified config files which otherwise contain a supressor
     * statement.
     */