static JSONStatus_t populateHttpStreamingFields()

in source/otaJobParser/job_parser.c [356:407]


static JSONStatus_t populateHttpStreamingFields( const char * jobDoc,
                                                 const size_t jobDocLength,
                                                 int32_t fileIndex,
                                                 AfrOtaJobDocumentFields_t * result )
{
    JSONStatus_t jsonResult = JSONNotFound;
    const char * jsonValue = NULL;
    size_t jsonValueLength = 0U;
    char queryString[ 33 ];
    size_t queryStringLength;

    buildIndexedFileQueryString( fileIndex,
                                 "auth_scheme",
                                 11U,
                                 queryString,
                                 &queryStringLength );
    jsonResult = JSON_SearchConst( jobDoc,
                                   jobDocLength,
                                   queryString,
                                   queryStringLength,
                                   &jsonValue,
                                   &jsonValueLength,
                                   NULL );
    result->authScheme = jsonValue;
    result->authSchemeLen = ( uint32_t ) jsonValueLength;

    if( jsonResult == JSONSuccess )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "update_data_url",
                                     15U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = JSON_SearchConst( jobDoc,
                                       jobDocLength,
                                       queryString,
                                       queryStringLength,
                                       &jsonValue,
                                       &jsonValueLength,
                                       NULL );
        result->imageRef = jsonValue;
        result->imageRefLen = ( uint32_t ) jsonValueLength;

        /* If the url is empty, consider this an error */
        if( jsonValueLength == 0U )
        {
            jsonResult = JSONNotFound;
        }
    }

    return jsonResult;
}