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 createMainQueue(qqueue_t** ppQueue, uchar* pszQueueName,
                         struct nvlst* lst)
{
    struct queuefilenames_s* qfn;
    uchar* qfname = NULL;
    static int qfn_renamenum = 0;
    uchar qfrenamebuf[1024];
    DEFiRet;

    /* create message queue */
    CHKiRet_Hdlr(qqueueConstruct(ppQueue, ourConf->globals.mainQ.MainMsgQueType,
                                 ourConf->globals.mainQ.iMainMsgQueueNumWorkers,
                                 ourConf->globals.mainQ.iMainMsgQueueSize,
                                 msgConsumer))
    {
        /* no queue is fatal, we need to give up in that case... */
        LogError(0, iRet, "could not create (ruleset) main message queue");
    }
    /* name our main queue object (it's not fatal if it fails...) */
    obj.SetName((obj_t*)(*ppQueue), pszQueueName);

    if (lst == NULL)
    {   /* use legacy parameters? */
        /* ... set some properties ... */
#define setQPROP(func, directive, data)                                        \
    CHKiRet_Hdlr(func(*ppQueue, data))                                         \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    }
#define setQPROPstr(func, directive, data)                                     \
    CHKiRet_Hdlr(                                                              \
        func(*ppQueue, data, (data == NULL) ? 0 : strlen((char*)data)))        \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    }

        if (ourConf->globals.mainQ.pszMainMsgQFName != NULL)
        {
            /* check if the queue file name is unique, else emit an error */
            for (qfn = queuefilenames; qfn != NULL; qfn = qfn->next)
            {
                dbgprintf("check queue file name '%s' vs '%s'\n", qfn->name,
                          ourConf->globals.mainQ.pszMainMsgQFName);
                if (!ustrcmp(qfn->name,
                             ourConf->globals.mainQ.pszMainMsgQFName))
                {
                    snprintf((char*)qfrenamebuf, sizeof(qfrenamebuf),
                             "%d-%s-%s", ++qfn_renamenum,
                             ourConf->globals.mainQ.pszMainMsgQFName,
                             (pszQueueName == NULL) ? "NONAME"
                                                    : (char*)pszQueueName);
                    qfname = ustrdup(qfrenamebuf);
                    LogError(0, NO_ERRCODE,
                             "Error: queue file name '%s' already in use "
                             " - using '%s' instead",
                             ourConf->globals.mainQ.pszMainMsgQFName, qfname);
                    break;
                }
            }
            if (qfname == NULL)
                qfname = ustrdup(ourConf->globals.mainQ.pszMainMsgQFName);
            qfn = malloc(sizeof(struct queuefilenames_s));
            qfn->name = qfname;
            qfn->next = queuefilenames;
            queuefilenames = qfn;
        }

        setQPROP(qqueueSetMaxFileSize, "$MainMsgQueueFileSize",
                 ourConf->globals.mainQ.iMainMsgQueMaxFileSize);
        setQPROP(qqueueSetsizeOnDiskMax, "$MainMsgQueueMaxDiskSpace",
                 ourConf->globals.mainQ.iMainMsgQueMaxDiskSpace);
        setQPROP(qqueueSetiDeqBatchSize, "$MainMsgQueueDequeueBatchSize",
                 ourConf->globals.mainQ.iMainMsgQueDeqBatchSize);
        setQPROPstr(qqueueSetFilePrefix, "$MainMsgQueueFileName", qfname);
        setQPROP(qqueueSetiPersistUpdCnt, "$MainMsgQueueCheckpointInterval",
                 ourConf->globals.mainQ.iMainMsgQPersistUpdCnt);
        setQPROP(qqueueSetbSyncQueueFiles, "$MainMsgQueueSyncQueueFiles",
                 ourConf->globals.mainQ.bMainMsgQSyncQeueFiles);
        setQPROP(qqueueSettoQShutdown, "$MainMsgQueueTimeoutShutdown",
                 ourConf->globals.mainQ.iMainMsgQtoQShutdown);
        setQPROP(qqueueSettoActShutdown, "$MainMsgQueueTimeoutActionCompletion",
                 ourConf->globals.mainQ.iMainMsgQtoActShutdown);
        setQPROP(qqueueSettoWrkShutdown,
                 "$MainMsgQueueWorkerTimeoutThreadShutdown",
                 ourConf->globals.mainQ.iMainMsgQtoWrkShutdown);
        setQPROP(qqueueSettoEnq, "$MainMsgQueueTimeoutEnqueue",
                 ourConf->globals.mainQ.iMainMsgQtoEnq);
        setQPROP(qqueueSetiHighWtrMrk, "$MainMsgQueueHighWaterMark",
                 ourConf->globals.mainQ.iMainMsgQHighWtrMark);
        setQPROP(qqueueSetiLowWtrMrk, "$MainMsgQueueLowWaterMark",
                 ourConf->globals.mainQ.iMainMsgQLowWtrMark);
        setQPROP(qqueueSetiDiscardMrk, "$MainMsgQueueDiscardMark",
                 ourConf->globals.mainQ.iMainMsgQDiscardMark);
        setQPROP(qqueueSetiDiscardSeverity, "$MainMsgQueueDiscardSeverity",
                 ourConf->globals.mainQ.iMainMsgQDiscardSeverity);
        setQPROP(qqueueSetiMinMsgsPerWrkr,
                 "$MainMsgQueueWorkerThreadMinimumMessages",
                 ourConf->globals.mainQ.iMainMsgQWrkMinMsgs);
        setQPROP(qqueueSetbSaveOnShutdown, "$MainMsgQueueSaveOnShutdown",
                 ourConf->globals.mainQ.bMainMsgQSaveOnShutdown);
        setQPROP(qqueueSetiDeqSlowdown, "$MainMsgQueueDequeueSlowdown",
                 ourConf->globals.mainQ.iMainMsgQDeqSlowdown);
        setQPROP(qqueueSetiDeqtWinFromHr, "$MainMsgQueueDequeueTimeBegin",
                 ourConf->globals.mainQ.iMainMsgQueueDeqtWinFromHr);
        setQPROP(qqueueSetiDeqtWinToHr, "$MainMsgQueueDequeueTimeEnd",
                 ourConf->globals.mainQ.iMainMsgQueueDeqtWinToHr);

#undef setQPROP
#undef setQPROPstr
    }
    else
    { /* use new style config! */
        qqueueSetDefaultsRulesetQueue(*ppQueue);
        qqueueApplyCnfParam(*ppQueue, lst);
    }
    RETiRet;
}
/* create a main message queue, now also used for ruleset queues. This function
 * needs to be moved to some other module, but it is considered acceptable for
 * the time being (remember that we want to restructure config processing at
 * large!). rgerhards, 2009-10-27
 */
create a main message queue, now also used for ruleset queues. This function
needs to be moved to some other module, but it is considered acceptable for
the time being (remember that we want to restructure config processing at
large!).
create a main message queue now also used for ruleset queues . This function needs to be moved to some other module but it is considered acceptable for the time being ( remember that we want to restructure config processing at large! ) .
rsRetVal createMainQueue(qqueue_t** ppQueue, uchar* pszQueueName,
                         struct nvlst* lst)
{
    struct queuefilenames_s* qfn;
    uchar* qfname = NULL;
    static int qfn_renamenum = 0;
    uchar qfrenamebuf[1024];
    DEFiRet;
    CHKiRet_Hdlr(qqueueConstruct(ppQueue, ourConf->globals.mainQ.MainMsgQueType,
                                 ourConf->globals.mainQ.iMainMsgQueueNumWorkers,
                                 ourConf->globals.mainQ.iMainMsgQueueSize,
                                 msgConsumer))
    {
        LogError(0, iRet, "could not create (ruleset) main message queue");
    }
    obj.SetName((obj_t*)(*ppQueue), pszQueueName);
    if (lst == NULL)
    {   
#define setQPROP(func, directive, data)                                        \
    CHKiRet_Hdlr(func(*ppQueue, data))                                         \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    }
#define setQPROPstr(func, directive, data)                                     \
    CHKiRet_Hdlr(                                                              \
        func(*ppQueue, data, (data == NULL) ? 0 : strlen((char*)data)))        \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    }
        if (ourConf->globals.mainQ.pszMainMsgQFName != NULL)
        {
            for (qfn = queuefilenames; qfn != NULL; qfn = qfn->next)
            {
                dbgprintf("check queue file name '%s' vs '%s'\n", qfn->name,
                          ourConf->globals.mainQ.pszMainMsgQFName);
                if (!ustrcmp(qfn->name,
                             ourConf->globals.mainQ.pszMainMsgQFName))
                {
                    snprintf((char*)qfrenamebuf, sizeof(qfrenamebuf),
                             "%d-%s-%s", ++qfn_renamenum,
                             ourConf->globals.mainQ.pszMainMsgQFName,
                             (pszQueueName == NULL) ? "NONAME"
                                                    : (char*)pszQueueName);
                    qfname = ustrdup(qfrenamebuf);
                    LogError(0, NO_ERRCODE,
                             "Error: queue file name '%s' already in use "
                             " - using '%s' instead",
                             ourConf->globals.mainQ.pszMainMsgQFName, qfname);
                    break;
                }
            }
            if (qfname == NULL)
                qfname = ustrdup(ourConf->globals.mainQ.pszMainMsgQFName);
            qfn = malloc(sizeof(struct queuefilenames_s));
            qfn->name = qfname;
            qfn->next = queuefilenames;
            queuefilenames = qfn;
        }
        setQPROP(qqueueSetMaxFileSize, "$MainMsgQueueFileSize",
                 ourConf->globals.mainQ.iMainMsgQueMaxFileSize);
        setQPROP(qqueueSetsizeOnDiskMax, "$MainMsgQueueMaxDiskSpace",
                 ourConf->globals.mainQ.iMainMsgQueMaxDiskSpace);
        setQPROP(qqueueSetiDeqBatchSize, "$MainMsgQueueDequeueBatchSize",
                 ourConf->globals.mainQ.iMainMsgQueDeqBatchSize);
        setQPROPstr(qqueueSetFilePrefix, "$MainMsgQueueFileName", qfname);
        setQPROP(qqueueSetiPersistUpdCnt, "$MainMsgQueueCheckpointInterval",
                 ourConf->globals.mainQ.iMainMsgQPersistUpdCnt);
        setQPROP(qqueueSetbSyncQueueFiles, "$MainMsgQueueSyncQueueFiles",
                 ourConf->globals.mainQ.bMainMsgQSyncQeueFiles);
        setQPROP(qqueueSettoQShutdown, "$MainMsgQueueTimeoutShutdown",
                 ourConf->globals.mainQ.iMainMsgQtoQShutdown);
        setQPROP(qqueueSettoActShutdown, "$MainMsgQueueTimeoutActionCompletion",
                 ourConf->globals.mainQ.iMainMsgQtoActShutdown);
        setQPROP(qqueueSettoWrkShutdown,
                 "$MainMsgQueueWorkerTimeoutThreadShutdown",
                 ourConf->globals.mainQ.iMainMsgQtoWrkShutdown);
        setQPROP(qqueueSettoEnq, "$MainMsgQueueTimeoutEnqueue",
                 ourConf->globals.mainQ.iMainMsgQtoEnq);
        setQPROP(qqueueSetiHighWtrMrk, "$MainMsgQueueHighWaterMark",
                 ourConf->globals.mainQ.iMainMsgQHighWtrMark);
        setQPROP(qqueueSetiLowWtrMrk, "$MainMsgQueueLowWaterMark",
                 ourConf->globals.mainQ.iMainMsgQLowWtrMark);
        setQPROP(qqueueSetiDiscardMrk, "$MainMsgQueueDiscardMark",
                 ourConf->globals.mainQ.iMainMsgQDiscardMark);
        setQPROP(qqueueSetiDiscardSeverity, "$MainMsgQueueDiscardSeverity",
                 ourConf->globals.mainQ.iMainMsgQDiscardSeverity);
        setQPROP(qqueueSetiMinMsgsPerWrkr,
                 "$MainMsgQueueWorkerThreadMinimumMessages",
                 ourConf->globals.mainQ.iMainMsgQWrkMinMsgs);
        setQPROP(qqueueSetbSaveOnShutdown, "$MainMsgQueueSaveOnShutdown",
                 ourConf->globals.mainQ.bMainMsgQSaveOnShutdown);
        setQPROP(qqueueSetiDeqSlowdown, "$MainMsgQueueDequeueSlowdown",
                 ourConf->globals.mainQ.iMainMsgQDeqSlowdown);
        setQPROP(qqueueSetiDeqtWinFromHr, "$MainMsgQueueDequeueTimeBegin",
                 ourConf->globals.mainQ.iMainMsgQueueDeqtWinFromHr);
        setQPROP(qqueueSetiDeqtWinToHr, "$MainMsgQueueDequeueTimeEnd",
                 ourConf->globals.mainQ.iMainMsgQueueDeqtWinToHr);
#undef setQPROP
#undef setQPROPstr
    }
    else
    { 
        qqueueSetDefaultsRulesetQueue(*ppQueue);
        qqueueApplyCnfParam(*ppQueue, lst);
    }
    RETiRet;
}
rsRetVal createMainQueue ( qqueue_t * * ppQueue , uchar * pszQueueName , struct nvlst * lst ) { struct queuefilenames_s * qfn ; uchar * qfname = NULL ; static int qfn_renamenum = 0 ; uchar qfrenamebuf [ 1024 ] ; DEFiRet ; CHKiRet_Hdlr ( qqueueConstruct ( ppQueue , ourConf -> globals . mainQ . MainMsgQueType , ourConf -> globals . mainQ . iMainMsgQueueNumWorkers , ourConf -> globals . mainQ . iMainMsgQueueSize , msgConsumer ) ) { LogError ( 0 , iRet , " " ) ; } obj . SetName ( ( obj_t * ) ( * ppQueue ) , pszQueueName ) ; if ( lst == NULL ) { #define setQPROP ( func , directive , data )                                         \
    CHKiRet_Hdlr(func(*ppQueue, data))                                         \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    } #define setQPROPstr ( func , directive , data )                                      \
    CHKiRet_Hdlr(                                                              \
        func(*ppQueue, data, (data == NULL) ? 0 : strlen((char*)data)))        \
    {                                                                          \
        LogError(0, NO_ERRCODE,                                                \
                 "Invalid " #directive ", error %d. Ignored, "                 \
                 "running with default setting",                               \
                 iRet);                                                        \
    } if ( ourConf -> globals . mainQ . pszMainMsgQFName != NULL ) { for ( qfn = queuefilenames ; qfn != NULL ; qfn = qfn -> next ) { dbgprintf ( " \n " , qfn -> name , ourConf -> globals . mainQ . pszMainMsgQFName ) ; if ( ! ustrcmp ( qfn -> name , ourConf -> globals . mainQ . pszMainMsgQFName ) ) { snprintf ( ( char * ) qfrenamebuf , sizeof ( qfrenamebuf ) , " " , ++ qfn_renamenum , ourConf -> globals . mainQ . pszMainMsgQFName , ( pszQueueName == NULL ) ? " " : ( char * ) pszQueueName ) ; qfname = ustrdup ( qfrenamebuf ) ; LogError ( 0 , NO_ERRCODE , " " " " , ourConf -> globals . mainQ . pszMainMsgQFName , qfname ) ; break ; } } if ( qfname == NULL ) qfname = ustrdup ( ourConf -> globals . mainQ . pszMainMsgQFName ) ; qfn = malloc ( sizeof ( struct queuefilenames_s ) ) ; qfn -> name = qfname ; qfn -> next = queuefilenames ; queuefilenames = qfn ; } setQPROP ( qqueueSetMaxFileSize , " " , ourConf -> globals . mainQ . iMainMsgQueMaxFileSize ) ; setQPROP ( qqueueSetsizeOnDiskMax , " " , ourConf -> globals . mainQ . iMainMsgQueMaxDiskSpace ) ; setQPROP ( qqueueSetiDeqBatchSize , " " , ourConf -> globals . mainQ . iMainMsgQueDeqBatchSize ) ; setQPROPstr ( qqueueSetFilePrefix , " " , qfname ) ; setQPROP ( qqueueSetiPersistUpdCnt , " " , ourConf -> globals . mainQ . iMainMsgQPersistUpdCnt ) ; setQPROP ( qqueueSetbSyncQueueFiles , " " , ourConf -> globals . mainQ . bMainMsgQSyncQeueFiles ) ; setQPROP ( qqueueSettoQShutdown , " " , ourConf -> globals . mainQ . iMainMsgQtoQShutdown ) ; setQPROP ( qqueueSettoActShutdown , " " , ourConf -> globals . mainQ . iMainMsgQtoActShutdown ) ; setQPROP ( qqueueSettoWrkShutdown , " " , ourConf -> globals . mainQ . iMainMsgQtoWrkShutdown ) ; setQPROP ( qqueueSettoEnq , " " , ourConf -> globals . mainQ . iMainMsgQtoEnq ) ; setQPROP ( qqueueSetiHighWtrMrk , " " , ourConf -> globals . mainQ . iMainMsgQHighWtrMark ) ; setQPROP ( qqueueSetiLowWtrMrk , " " , ourConf -> globals . mainQ . iMainMsgQLowWtrMark ) ; setQPROP ( qqueueSetiDiscardMrk , " " , ourConf -> globals . mainQ . iMainMsgQDiscardMark ) ; setQPROP ( qqueueSetiDiscardSeverity , " " , ourConf -> globals . mainQ . iMainMsgQDiscardSeverity ) ; setQPROP ( qqueueSetiMinMsgsPerWrkr , " " , ourConf -> globals . mainQ . iMainMsgQWrkMinMsgs ) ; setQPROP ( qqueueSetbSaveOnShutdown , " " , ourConf -> globals . mainQ . bMainMsgQSaveOnShutdown ) ; setQPROP ( qqueueSetiDeqSlowdown , " " , ourConf -> globals . mainQ . iMainMsgQDeqSlowdown ) ; setQPROP ( qqueueSetiDeqtWinFromHr , " " , ourConf -> globals . mainQ . iMainMsgQueueDeqtWinFromHr ) ; setQPROP ( qqueueSetiDeqtWinToHr , " " , ourConf -> globals . mainQ . iMainMsgQueueDeqtWinToHr ) ; #undef  setQPROP #undef  setQPROPstr } else { qqueueSetDefaultsRulesetQueue ( * ppQueue ) ; qqueueApplyCnfParam ( * ppQueue , lst ) ; } RETiRet ; }
create a main message queue, now also used for ruleset queues.
create a main message queue now also used for ruleset queues .
/* create message queue */ /* no queue is fatal, we need to give up in that case... */ /* name our main queue object (it's not fatal if it fails...) */ /* use legacy parameters? */ /* ... set some properties ... */ /* check if the queue file name is unique, else emit an error */ /* use new style config! */