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/msg.c
static rsRetVal jsonField(struct templateEntry * pTpe, uchar * *ppRes,
                              unsigned short* pbMustBeFreed, int* pBufLen,
                              int escapeAll)
    {
        unsigned buflen;
        uchar* pSrc;
        es_str_t* dst = NULL;
        DEFiRet;

        pSrc = *ppRes;
        buflen = (*pBufLen == -1) ? (int)ustrlen(pSrc) : *pBufLen;
        /* we hope we have only few escapes... */
        dst = es_newStr(buflen + pTpe->lenFieldName + 15);
        es_addChar(&dst, '"');
        es_addBuf(&dst, (char*)pTpe->fieldName, pTpe->lenFieldName);
        es_addBufConstcstr(&dst, "\":\"");
        CHKiRet(jsonAddVal(pSrc, buflen, &dst, escapeAll));
        es_addChar(&dst, '"');

        if (*pbMustBeFreed)
            free(*ppRes);
        /* we know we do not have \0 chars - so the size does not change */
        *pBufLen = es_strlen(dst);
        *ppRes = (uchar*)es_str2cstr(dst, NULL);
        *pbMustBeFreed = 1;
        es_deleteStr(dst);

    finalize_it:
        RETiRet;
    }
/* Format a property as JSON field, that means
     * "name"="value"
     * where value is JSON-escaped (here we assume that the name
     * only contains characters from the valid character set).
     * Note: this function duplicates code from jsonEncode().
     * TODO: these two functions should be combined, at least if
     * that makes any sense from a performance PoV - definitely
     * something to consider at a later stage. rgerhards, 2012-04-19
     */
Format a property as JSON field, that means
"name"="value"
where value is JSON-escaped (here we assume that the name
only contains characters from the valid character set).
Note: this function duplicates code from jsonEncode().
TODO: these two functions should be combined, at least if
that makes any sense from a performance PoV - definitely
something to consider at a later stage.
Format a property as JSON field that means " name " = " value " where value is JSON - escaped ( here we assume that the name only contains characters from the valid character set ) . Note : this function duplicates code from jsonEncode () . TODO : these two functions should be combined at least if that makes any sense from a performance PoV - definitely something to consider at a later stage .
static rsRetVal jsonField(struct templateEntry * pTpe, uchar * *ppRes,
                              unsigned short* pbMustBeFreed, int* pBufLen,
                              int escapeAll)
    {
        unsigned buflen;
        uchar* pSrc;
        es_str_t* dst = NULL;
        DEFiRet;
        pSrc = *ppRes;
        buflen = (*pBufLen == -1) ? (int)ustrlen(pSrc) : *pBufLen;
        dst = es_newStr(buflen + pTpe->lenFieldName + 15);
        es_addChar(&dst, '"');
        es_addBuf(&dst, (char*)pTpe->fieldName, pTpe->lenFieldName);
        es_addBufConstcstr(&dst, "\":\"");
        CHKiRet(jsonAddVal(pSrc, buflen, &dst, escapeAll));
        es_addChar(&dst, '"');
        if (*pbMustBeFreed)
            free(*ppRes);
        *pBufLen = es_strlen(dst);
        *ppRes = (uchar*)es_str2cstr(dst, NULL);
        *pbMustBeFreed = 1;
        es_deleteStr(dst);
    finalize_it:
        RETiRet;
    }
static rsRetVal jsonField ( struct templateEntry * pTpe , uchar * * ppRes , unsigned short * pbMustBeFreed , int * pBufLen , int escapeAll ) { unsigned buflen ; uchar * pSrc ; es_str_t * dst = NULL ; DEFiRet ; pSrc = * ppRes ; buflen = ( * pBufLen == -1 ) ? ( int ) ustrlen ( pSrc ) : * pBufLen ; dst = es_newStr ( buflen + pTpe -> lenFieldName + 15 ) ; es_addChar ( & dst , ' ' ) ; es_addBuf ( & dst , ( char * ) pTpe -> fieldName , pTpe -> lenFieldName ) ; es_addBufConstcstr ( & dst , " \" \" " ) ; CHKiRet ( jsonAddVal ( pSrc , buflen , & dst , escapeAll ) ) ; es_addChar ( & dst , ' ' ) ; if ( * pbMustBeFreed ) free ( * ppRes ) ; * pBufLen = es_strlen ( dst ) ; * ppRes = ( uchar * ) es_str2cstr ( dst , NULL ) ; * pbMustBeFreed = 1 ; es_deleteStr ( dst ) ; finalize_it : RETiRet ; }
Format a property as JSON field, that means
 "name"="value"
 where value is JSON-escaped (here we assume that the name
 only contains characters from the valid character set).
Format a property as JSON field that means " name " = " value " where value is JSON - escaped ( here we assume that the name only contains characters from the valid character set ) .
/* we hope we have only few escapes... */ /* we know we do not have \0 chars - so the size does not change */