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/rsyslog.c
rsRetVal rsrtInit(const char** ppErrObj, obj_if_t* pObjIF)
{
    DEFiRet;
    int ret;
    char errstr[1024];

    if (iRefCount == 0)
    {
        seedRandomNumber();
        /* init runtime only if not yet done */
#ifdef ENABLE_LIBLOGGING_STDLOG
        stdlog_init(0);
        stdlog_hdl = stdlog_open("rsyslogd", 0, STDLOG_SYSLOG, NULL);
#endif
        ret = pthread_attr_init(&default_thread_attr);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_init failed during "
                    "startup - can not continue. Error was %s\n",
                    errstr);
            exit(1);
        }
        pthread_attr_setstacksize(&default_thread_attr, 4096 * 1024);
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
        ret = pthread_getschedparam(pthread_self(), &default_thr_sched_policy,
                                    &default_sched_param);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_getschedparam failed during "
                    "startup - ignoring. Error was %s\n",
                    errstr);
            default_thr_sched_policy =
                0; /* should be default on all platforms */
        }
#if defined(_AIX)
        pthread_attr_setstacksize(&default_thread_attr, 4096 * 512);
#endif

        ret = pthread_attr_setschedpolicy(&default_thread_attr,
                                          default_thr_sched_policy);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setschedpolicy failed during "
                    "startup - tried to set priority %d, now using default "
                    "priority instead. Error was: %s\n",
                    default_thr_sched_policy, errstr);
        }
        ret = pthread_attr_setschedparam(&default_thread_attr,
                                         &default_sched_param);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setschedparam failed during "
                    "startup - ignored Error was: %s\n",
                    errstr);
        }
        ret = pthread_attr_setinheritsched(&default_thread_attr,
                                           PTHREAD_EXPLICIT_SCHED);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setinheritsched failed during "
                    "startup - ignoring. Error was: %s\n",
                    errstr);
        }
#endif
        if (ppErrObj != NULL)
            *ppErrObj = "obj";
        CHKiRet(objClassInit(NULL)); /* *THIS* *MUST* always be the first class
                                        initilizer being called! */
        CHKiRet(objGetObjInterface(
            pObjIF)); /* this provides the root pointer for all other queries */

        /* initialize core classes. We must be very careful with the order of
         * events. Some classes use others and if we do not initialize them in
         * the right order, we may end up with an invalid call. The most
         * important thing that can happen is that an error is detected and
         * needs to be logged, wich in turn requires a broader number of classes
         * to be available. The solution is that we take care in the order of
         * calls AND use a class immediately after it is initialized. And, of
         * course, we load those classes first that we use ourselfs... --
         * rgerhards, 2008-03-07
         */
        if (ppErrObj != NULL)
            *ppErrObj = "statsobj";
        CHKiRet(statsobjClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "prop";
        CHKiRet(propClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "glbl";
        CHKiRet(glblClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "msg";
        CHKiRet(msgClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "ruleset";
        CHKiRet(rulesetClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "wti";
        CHKiRet(wtiClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "wtp";
        CHKiRet(wtpClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "queue";
        CHKiRet(qqueueClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "conf";
        CHKiRet(confClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "parser";
        CHKiRet(parserClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "strgen";
        CHKiRet(strgenClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "rsconf";
        CHKiRet(rsconfClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "lookup";
        CHKiRet(lookupClassInit());
        if (ppErrObj != NULL)
            *ppErrObj = "dynstats";
        CHKiRet(dynstatsClassInit());

        /* dummy "classes" */
        if (ppErrObj != NULL)
            *ppErrObj = "str";
        CHKiRet(strInit());
    }

    ++iRefCount;
    dbgprintf("rsyslog runtime initialized, version %s, current users %d\n",
              VERSION, iRefCount);

finalize_it:
    RETiRet;
}
/* globally initialze the runtime system
 * NOTE: this is NOT thread safe and must not be called concurrently. If that
 * ever poses a problem, we may use proper mutex calls - not considered needed
 * yet. If ppErrObj is provided, it receives a char pointer to the name of the
 * object that caused the problem (if one occured). The caller must never free
 * this pointer. If ppErrObj is NULL, no such information will be provided.
 * pObjIF is the pointer to the "obj" object interface, which may be used to
 * query any other rsyslog objects. rgerhards, 2008-04-16
 */
globally initialze the runtime system
NOTE: this is NOT thread safe and must not be called concurrently. If that
ever poses a problem, we may use proper mutex calls - not considered needed
yet. If ppErrObj is provided, it receives a char pointer to the name of the
object that caused the problem (if one occured). The caller must never free
this pointer. If ppErrObj is NULL, no such information will be provided.
pObjIF is the pointer to the "obj" object interface, which may be used to
query any other rsyslog objects.
globally initialze the runtime system NOTE : this is NOT thread safe and must not be called concurrently . If that ever poses a problem we may use proper mutex calls - not considered needed yet . If ppErrObj is provided it receives a char pointer to the name of the object that caused the problem ( if one occured ) . The caller must never free this pointer . If ppErrObj is NULL no such information will be provided . pObjIF is the pointer to the " obj " object interface which may be used to query any other rsyslog objects .
rsRetVal rsrtInit(const char** ppErrObj, obj_if_t* pObjIF)
{
    DEFiRet;
    int ret;
    char errstr[1024];
    if (iRefCount == 0)
    {
        seedRandomNumber();
#ifdef ENABLE_LIBLOGGING_STDLOG
        stdlog_init(0);
        stdlog_hdl = stdlog_open("rsyslogd", 0, STDLOG_SYSLOG, NULL);
#endif
        ret = pthread_attr_init(&default_thread_attr);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_init failed during "
                    "startup - can not continue. Error was %s\n",
                    errstr);
            exit(1);
        }
        pthread_attr_setstacksize(&default_thread_attr, 4096 * 1024);
#ifdef HAVE_PTHREAD_SETSCHEDPARAM
        ret = pthread_getschedparam(pthread_self(), &default_thr_sched_policy,
                                    &default_sched_param);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_getschedparam failed during "
                    "startup - ignoring. Error was %s\n",
                    errstr);
            default_thr_sched_policy =
                0; 
        }
#if defined(_AIX)
        pthread_attr_setstacksize(&default_thread_attr, 4096 * 512);
#endif
        ret = pthread_attr_setschedpolicy(&default_thread_attr,
                                          default_thr_sched_policy);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setschedpolicy failed during "
                    "startup - tried to set priority %d, now using default "
                    "priority instead. Error was: %s\n",
                    default_thr_sched_policy, errstr);
        }
        ret = pthread_attr_setschedparam(&default_thread_attr,
                                         &default_sched_param);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setschedparam failed during "
                    "startup - ignored Error was: %s\n",
                    errstr);
        }
        ret = pthread_attr_setinheritsched(&default_thread_attr,
                                           PTHREAD_EXPLICIT_SCHED);
        if (ret != 0)
        {
            rs_strerror_r(ret, errstr, sizeof(errstr));
            fprintf(stderr,
                    "rsyslogd: pthread_attr_setinheritsched failed during "
                    "startup - ignoring. Error was: %s\n",
                    errstr);
        }
#endif
        if (ppErrObj != NULL)
            *ppErrObj = "obj";
        CHKiRet(objClassInit(NULL)); 
        CHKiRet(objGetObjInterface(
            pObjIF)); 
        if (ppErrObj != NULL)
            *ppErrObj = "statsobj";
        CHKiRet(statsobjClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "prop";
        CHKiRet(propClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "glbl";
        CHKiRet(glblClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "msg";
        CHKiRet(msgClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "ruleset";
        CHKiRet(rulesetClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "wti";
        CHKiRet(wtiClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "wtp";
        CHKiRet(wtpClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "queue";
        CHKiRet(qqueueClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "conf";
        CHKiRet(confClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "parser";
        CHKiRet(parserClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "strgen";
        CHKiRet(strgenClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "rsconf";
        CHKiRet(rsconfClassInit(NULL));
        if (ppErrObj != NULL)
            *ppErrObj = "lookup";
        CHKiRet(lookupClassInit());
        if (ppErrObj != NULL)
            *ppErrObj = "dynstats";
        CHKiRet(dynstatsClassInit());
        if (ppErrObj != NULL)
            *ppErrObj = "str";
        CHKiRet(strInit());
    }
    ++iRefCount;
    dbgprintf("rsyslog runtime initialized, version %s, current users %d\n",
              VERSION, iRefCount);
finalize_it:
    RETiRet;
}
rsRetVal rsrtInit ( const char * * ppErrObj , obj_if_t * pObjIF ) { DEFiRet ; int ret ; char errstr [ 1024 ] ; if ( iRefCount == 0 ) { seedRandomNumber ( ) ; #ifdef ENABLE_LIBLOGGING_STDLOG stdlog_init ( 0 ) ; stdlog_hdl = stdlog_open ( " " , 0 , STDLOG_SYSLOG , NULL ) ; #endif ret = pthread_attr_init ( & default_thread_attr ) ; if ( ret != 0 ) { rs_strerror_r ( ret , errstr , sizeof ( errstr ) ) ; fprintf ( stderr , " " " \n " , errstr ) ; exit ( 1 ) ; } pthread_attr_setstacksize ( & default_thread_attr , 4096 * 1024 ) ; #ifdef HAVE_PTHREAD_SETSCHEDPARAM ret = pthread_getschedparam ( pthread_self ( ) , & default_thr_sched_policy , & default_sched_param ) ; if ( ret != 0 ) { rs_strerror_r ( ret , errstr , sizeof ( errstr ) ) ; fprintf ( stderr , " " " \n " , errstr ) ; default_thr_sched_policy = 0 ; } #if defined ( _AIX ) pthread_attr_setstacksize ( & default_thread_attr , 4096 * 512 ) ; #endif ret = pthread_attr_setschedpolicy ( & default_thread_attr , default_thr_sched_policy ) ; if ( ret != 0 ) { rs_strerror_r ( ret , errstr , sizeof ( errstr ) ) ; fprintf ( stderr , " " " " " \n " , default_thr_sched_policy , errstr ) ; } ret = pthread_attr_setschedparam ( & default_thread_attr , & default_sched_param ) ; if ( ret != 0 ) { rs_strerror_r ( ret , errstr , sizeof ( errstr ) ) ; fprintf ( stderr , " " " \n " , errstr ) ; } ret = pthread_attr_setinheritsched ( & default_thread_attr , PTHREAD_EXPLICIT_SCHED ) ; if ( ret != 0 ) { rs_strerror_r ( ret , errstr , sizeof ( errstr ) ) ; fprintf ( stderr , " " " \n " , errstr ) ; } #endif if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( objClassInit ( NULL ) ) ; CHKiRet ( objGetObjInterface ( pObjIF ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( statsobjClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( propClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( glblClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( msgClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( rulesetClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( wtiClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( wtpClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( qqueueClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( confClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( parserClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( strgenClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( rsconfClassInit ( NULL ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( lookupClassInit ( ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( dynstatsClassInit ( ) ) ; if ( ppErrObj != NULL ) * ppErrObj = " " ; CHKiRet ( strInit ( ) ) ; } ++ iRefCount ; dbgprintf ( " \n " , VERSION , iRefCount ) ; finalize_it : RETiRet ; }
globally initialze the runtime system
 NOTE: this is NOT thread safe and must not be called concurrently.
globally initialze the runtime system NOTE : this is NOT thread safe and must not be called concurrently .
/* init runtime only if not yet done */ /* should be default on all platforms */ /* *THIS* *MUST* always be the first class
                                        initilizer being called! */ /* this provides the root pointer for all other queries */ /* initialize core classes. We must be very careful with the order of
         * events. Some classes use others and if we do not initialize them in
         * the right order, we may end up with an invalid call. The most
         * important thing that can happen is that an error is detected and
         * needs to be logged, wich in turn requires a broader number of classes
         * to be available. The solution is that we take care in the order of
         * calls AND use a class immediately after it is initialized. And, of
         * course, we load those classes first that we use ourselfs... --
         * rgerhards, 2008-03-07
         */ /* dummy "classes" */