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/runtime/conf.c
rsRetVal DecodePRIFilter(uchar* pline, uchar pmask[])
{
    uchar* p;
    register uchar* q;
    register int i, i2;
    uchar* bp;
    int pri; /* this MUST be int, as -1 is used to convey an error state */
    int singlpri = 0;
    int ignorepri = 0;
    uchar buf[2048]; /* buffer for facility and priority names */
    uchar xbuf[200];
    DEFiRet;

    assert(pline != NULL);

    dbgprintf("Decoding traditional PRI filter '%s'\n", pline);

    for (i = 0; i <= LOG_NFACILITIES; i++)
    {
        pmask[i] = TABLE_NOPRI;
    }

    /* scan through the list of selectors */
    for (p = pline; *p && *p != '\t' && *p != ' ';)
    {
        /* find the end of this facility name list */
        for (q = p; *q && *q != '\t' && *q++ != '.';)
            continue;

        /* collect priority name */
        for (bp = buf;
             *q && !strchr("\t ,;", *q) && bp < buf + sizeof(buf) - 1;)
            *bp++ = *q++;
        *bp = '\0';

        /* skip cruft */
        if (*q)
        {
            while (strchr(",;", *q))
                q++;
        }

        /* decode priority name */
        if (*buf == '!')
        {
            ignorepri = 1;
            /* copy below is ok, we can NOT go off the allocated area */
            for (bp = buf; *(bp + 1); bp++)
                *bp = *(bp + 1);
            *bp = '\0';
        }
        else
        {
            ignorepri = 0;
        }
        if (*buf == '=')
        {
            singlpri = 1;
            pri = decodeSyslogName(&buf[1], syslogPriNames);
        }
        else
        {
            singlpri = 0;
            pri = decodeSyslogName(buf, syslogPriNames);
        }

        if (pri < 0)
        {
            snprintf((char*)xbuf, sizeof(xbuf), "unknown priority name \"%s\"",
                     buf);
            LogError(0, RS_RET_ERR, "%s", xbuf);
            return RS_RET_ERR;
        }

        /* scan facilities */
        while (*p && !strchr("\t .;", *p))
        {
            for (bp = buf;
                 *p && !strchr("\t ,;.", *p) && bp < buf + sizeof(buf) - 1;)
                *bp++ = *p++;
            *bp = '\0';
            if (*buf == '*')
            {
                for (i = 0; i <= LOG_NFACILITIES; i++)
                {
                    if (pri == INTERNAL_NOPRI)
                    {
                        if (ignorepri)
                            pmask[i] = TABLE_ALLPRI;
                        else
                            pmask[i] = TABLE_NOPRI;
                    }
                    else if (singlpri)
                    {
                        if (ignorepri)
                            pmask[i] &= ~(1 << pri);
                        else
                            pmask[i] |= (1 << pri);
                    }
                    else
                    {
                        if (pri == TABLE_ALLPRI)
                        {
                            if (ignorepri)
                                pmask[i] = TABLE_NOPRI;
                            else
                                pmask[i] = TABLE_ALLPRI;
                        }
                        else
                        {
                            if (ignorepri)
                                for (i2 = 0; i2 <= pri; ++i2)
                                    pmask[i] &= ~(1 << i2);
                            else
                                for (i2 = 0; i2 <= pri; ++i2)
                                    pmask[i] |= (1 << i2);
                        }
                    }
                }
            }
            else
            {
                i = decodeSyslogName(buf, syslogFacNames);
                if (i < 0)
                {

                    snprintf((char*)xbuf, sizeof(xbuf),
                             "unknown facility name \"%s\"", buf);
                    LogError(0, RS_RET_ERR, "%s", xbuf);
                    return RS_RET_ERR;
                }

                if (pri == INTERNAL_NOPRI)
                {
                    if (ignorepri)
                        pmask[i >> 3] = TABLE_ALLPRI;
                    else
                        pmask[i >> 3] = TABLE_NOPRI;
                }
                else if (singlpri)
                {
                    if (ignorepri)
                        pmask[i >> 3] &= ~(1 << pri);
                    else
                        pmask[i >> 3] |= (1 << pri);
                }
                else
                {
                    if (pri == TABLE_ALLPRI)
                    {
                        if (ignorepri)
                            pmask[i >> 3] = TABLE_NOPRI;
                        else
                            pmask[i >> 3] = TABLE_ALLPRI;
                    }
                    else
                    {
                        if (ignorepri)
                            for (i2 = 0; i2 <= pri; ++i2)
                                pmask[i >> 3] &= ~(1 << i2);
                        else
                            for (i2 = 0; i2 <= pri; ++i2)
                                pmask[i >> 3] |= (1 << i2);
                    }
                }
            }
            while (*p == ',' || *p == ' ')
                p++;
        }

        p = q;
    }

    RETiRet;
}
/* Decode a traditional PRI filter */
/* GPLv3 - stems back to sysklogd */
Decode a traditional PRI filter
GPLv3 - stems back to sysklogd
Decode a traditional PRI filter GPLv3 - stems back to sysklogd
rsRetVal DecodePRIFilter(uchar* pline, uchar pmask[])
{
    uchar* p;
    register uchar* q;
    register int i, i2;
    uchar* bp;
    int pri; 
    int singlpri = 0;
    int ignorepri = 0;
    uchar buf[2048]; 
    uchar xbuf[200];
    DEFiRet;
    assert(pline != NULL);
    dbgprintf("Decoding traditional PRI filter '%s'\n", pline);
    for (i = 0; i <= LOG_NFACILITIES; i++)
    {
        pmask[i] = TABLE_NOPRI;
    }
    for (p = pline; *p && *p != '\t' && *p != ' ';)
    {
        for (q = p; *q && *q != '\t' && *q++ != '.';)
            continue;
        for (bp = buf;
             *q && !strchr("\t ,;", *q) && bp < buf + sizeof(buf) - 1;)
            *bp++ = *q++;
        *bp = '\0';
        if (*q)
        {
            while (strchr(",;", *q))
                q++;
        }
        if (*buf == '!')
        {
            ignorepri = 1;
            for (bp = buf; *(bp + 1); bp++)
                *bp = *(bp + 1);
            *bp = '\0';
        }
        else
        {
            ignorepri = 0;
        }
        if (*buf == '=')
        {
            singlpri = 1;
            pri = decodeSyslogName(&buf[1], syslogPriNames);
        }
        else
        {
            singlpri = 0;
            pri = decodeSyslogName(buf, syslogPriNames);
        }
        if (pri < 0)
        {
            snprintf((char*)xbuf, sizeof(xbuf), "unknown priority name \"%s\"",
                     buf);
            LogError(0, RS_RET_ERR, "%s", xbuf);
            return RS_RET_ERR;
        }
        while (*p && !strchr("\t .;", *p))
        {
            for (bp = buf;
                 *p && !strchr("\t ,;.", *p) && bp < buf + sizeof(buf) - 1;)
                *bp++ = *p++;
            *bp = '\0';
            if (*buf == '*')
            {
                for (i = 0; i <= LOG_NFACILITIES; i++)
                {
                    if (pri == INTERNAL_NOPRI)
                    {
                        if (ignorepri)
                            pmask[i] = TABLE_ALLPRI;
                        else
                            pmask[i] = TABLE_NOPRI;
                    }
                    else if (singlpri)
                    {
                        if (ignorepri)
                            pmask[i] &= ~(1 << pri);
                        else
                            pmask[i] |= (1 << pri);
                    }
                    else
                    {
                        if (pri == TABLE_ALLPRI)
                        {
                            if (ignorepri)
                                pmask[i] = TABLE_NOPRI;
                            else
                                pmask[i] = TABLE_ALLPRI;
                        }
                        else
                        {
                            if (ignorepri)
                                for (i2 = 0; i2 <= pri; ++i2)
                                    pmask[i] &= ~(1 << i2);
                            else
                                for (i2 = 0; i2 <= pri; ++i2)
                                    pmask[i] |= (1 << i2);
                        }
                    }
                }
            }
            else
            {
                i = decodeSyslogName(buf, syslogFacNames);
                if (i < 0)
                {
                    snprintf((char*)xbuf, sizeof(xbuf),
                             "unknown facility name \"%s\"", buf);
                    LogError(0, RS_RET_ERR, "%s", xbuf);
                    return RS_RET_ERR;
                }
                if (pri == INTERNAL_NOPRI)
                {
                    if (ignorepri)
                        pmask[i >> 3] = TABLE_ALLPRI;
                    else
                        pmask[i >> 3] = TABLE_NOPRI;
                }
                else if (singlpri)
                {
                    if (ignorepri)
                        pmask[i >> 3] &= ~(1 << pri);
                    else
                        pmask[i >> 3] |= (1 << pri);
                }
                else
                {
                    if (pri == TABLE_ALLPRI)
                    {
                        if (ignorepri)
                            pmask[i >> 3] = TABLE_NOPRI;
                        else
                            pmask[i >> 3] = TABLE_ALLPRI;
                    }
                    else
                    {
                        if (ignorepri)
                            for (i2 = 0; i2 <= pri; ++i2)
                                pmask[i >> 3] &= ~(1 << i2);
                        else
                            for (i2 = 0; i2 <= pri; ++i2)
                                pmask[i >> 3] |= (1 << i2);
                    }
                }
            }
            while (*p == ',' || *p == ' ')
                p++;
        }
        p = q;
    }
    RETiRet;
}
rsRetVal DecodePRIFilter ( uchar * pline , uchar pmask [ ] ) { uchar * p ; register uchar * q ; register int i , i2 ; uchar * bp ; int pri ; int singlpri = 0 ; int ignorepri = 0 ; uchar buf [ 2048 ] ; uchar xbuf [ 200 ] ; DEFiRet ; assert ( pline != NULL ) ; dbgprintf ( " \n " , pline ) ; for ( i = 0 ; i <= LOG_NFACILITIES ; i ++ ) { pmask [ i ] = TABLE_NOPRI ; } for ( p = pline ; * p && * p != ' \t ' && * p != ' ' ; ) { for ( q = p ; * q && * q != ' \t ' && * q ++ != ' ' ; ) continue ; for ( bp = buf ; * q && ! strchr ( " \t " , * q ) && bp < buf + sizeof ( buf ) - 1 ; ) * bp ++ = * q ++ ; * bp = ' \0 ' ; if ( * q ) { while ( strchr ( " " , * q ) ) q ++ ; } if ( * buf == ' ' ) { ignorepri = 1 ; for ( bp = buf ; * ( bp + 1 ) ; bp ++ ) * bp = * ( bp + 1 ) ; * bp = ' \0 ' ; } else { ignorepri = 0 ; } if ( * buf == ' ' ) { singlpri = 1 ; pri = decodeSyslogName ( & buf [ 1 ] , syslogPriNames ) ; } else { singlpri = 0 ; pri = decodeSyslogName ( buf , syslogPriNames ) ; } if ( pri < 0 ) { snprintf ( ( char * ) xbuf , sizeof ( xbuf ) , " \" \" " , buf ) ; LogError ( 0 , RS_RET_ERR , " " , xbuf ) ; return RS_RET_ERR ; } while ( * p && ! strchr ( " \t " , * p ) ) { for ( bp = buf ; * p && ! strchr ( " \t " , * p ) && bp < buf + sizeof ( buf ) - 1 ; ) * bp ++ = * p ++ ; * bp = ' \0 ' ; if ( * buf == ' ' ) { for ( i = 0 ; i <= LOG_NFACILITIES ; i ++ ) { if ( pri == INTERNAL_NOPRI ) { if ( ignorepri ) pmask [ i ] = TABLE_ALLPRI ; else pmask [ i ] = TABLE_NOPRI ; } else if ( singlpri ) { if ( ignorepri ) pmask [ i ] &= ~ ( 1 << pri ) ; else pmask [ i ] |= ( 1 << pri ) ; } else { if ( pri == TABLE_ALLPRI ) { if ( ignorepri ) pmask [ i ] = TABLE_NOPRI ; else pmask [ i ] = TABLE_ALLPRI ; } else { if ( ignorepri ) for ( i2 = 0 ; i2 <= pri ; ++ i2 ) pmask [ i ] &= ~ ( 1 << i2 ) ; else for ( i2 = 0 ; i2 <= pri ; ++ i2 ) pmask [ i ] |= ( 1 << i2 ) ; } } } } else { i = decodeSyslogName ( buf , syslogFacNames ) ; if ( i < 0 ) { snprintf ( ( char * ) xbuf , sizeof ( xbuf ) , " \" \" " , buf ) ; LogError ( 0 , RS_RET_ERR , " " , xbuf ) ; return RS_RET_ERR ; } if ( pri == INTERNAL_NOPRI ) { if ( ignorepri ) pmask [ i >> 3 ] = TABLE_ALLPRI ; else pmask [ i >> 3 ] = TABLE_NOPRI ; } else if ( singlpri ) { if ( ignorepri ) pmask [ i >> 3 ] &= ~ ( 1 << pri ) ; else pmask [ i >> 3 ] |= ( 1 << pri ) ; } else { if ( pri == TABLE_ALLPRI ) { if ( ignorepri ) pmask [ i >> 3 ] = TABLE_NOPRI ; else pmask [ i >> 3 ] = TABLE_ALLPRI ; } else { if ( ignorepri ) for ( i2 = 0 ; i2 <= pri ; ++ i2 ) pmask [ i >> 3 ] &= ~ ( 1 << i2 ) ; else for ( i2 = 0 ; i2 <= pri ; ++ i2 ) pmask [ i >> 3 ] |= ( 1 << i2 ) ; } } } while ( * p == ' ' || * p == ' ' ) p ++ ; } p = q ; } RETiRet ; }
Decode a traditional PRI filter
GPLv3 - stems back to sysklogd
Decode a traditional PRI filter GPLv3 - stems back to sysklogd
/* this MUST be int, as -1 is used to convey an error state */ /* buffer for facility and priority names */ /* scan through the list of selectors */ /* find the end of this facility name list */ /* collect priority name */ /* skip cruft */ /* decode priority name */ /* copy below is ok, we can NOT go off the allocated area */ /* scan facilities */