static JSONStatus_t populateCommonFields()

in source/otaJobParser/job_parser.c [198:304]


static JSONStatus_t populateCommonFields( 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;

    if( fileIndex <= 9 )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "filesize",
                                     8U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = searchUintValue( jobDoc,
                                      jobDocLength,
                                      queryString,
                                      queryStringLength,
                                      &( result->fileSize ) );
    }
    else
    {
        jsonResult = JSONIllegalDocument;
    }

    if( jsonResult == JSONSuccess )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "fileid",
                                     6U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = searchUintValue( jobDoc,
                                      jobDocLength,
                                      queryString,
                                      queryStringLength,
                                      &( result->fileId ) );
    }

    if( jsonResult == JSONSuccess )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "filepath",
                                     8U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = JSON_SearchConst( jobDoc,
                                       jobDocLength,
                                       queryString,
                                       queryStringLength,
                                       &jsonValue,
                                       &jsonValueLength,
                                       NULL );
        result->filepath = jsonValue;
        result->filepathLen = ( uint32_t ) jsonValueLength;
    }

    if( jsonResult == JSONSuccess )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "certfile",
                                     8U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = JSON_SearchConst( jobDoc,
                                       jobDocLength,
                                       queryString,
                                       queryStringLength,
                                       &jsonValue,
                                       &jsonValueLength,
                                       NULL );
        result->certfile = jsonValue;
        result->certfileLen = ( uint32_t ) jsonValueLength;
    }

    if( jsonResult == JSONSuccess )
    {
        buildIndexedFileQueryString( fileIndex,
                                     "sig-sha256-ecdsa",
                                     16U,
                                     queryString,
                                     &queryStringLength );
        jsonResult = JSON_SearchConst( jobDoc,
                                       jobDocLength,
                                       queryString,
                                       queryStringLength,
                                       &jsonValue,
                                       &jsonValueLength,
                                       NULL );
        result->signature = jsonValue;
        result->signatureLen = ( uint32_t ) jsonValueLength;
    }

    if( jsonResult == JSONSuccess )
    {
        jsonResult = populateOptionalCommonFields( jobDoc,
                                                   jobDocLength,
                                                   fileIndex,
                                                   result );
    }

    return jsonResult;
}