Glasswall Document Processing - Memory to Memory Location
    • PDF

    Glasswall Document Processing - Memory to Memory Location

    • PDF

    Article summary

    Glasswall Document Processing - Memory to Memory Location

    These functions process the document provided in a specified memory location and publish the resulting output to memory locations. Each of the function signatures requires the client application to provide a location to which the report or regenerated document can be written, along with a variable in which the size of the output is recorded. If the output file is not required, null pointers can be specified.

    Parameters of type pointer to pointer are used by Glasswall to allocate memory for storing processed files and analysis reports. The client accesses the buffers through these parameters but is otherwise not responsible for managing the allocated memory except that GWFileDone must be called when processing is finished in order to release the allocated memory.

    Functions

    • int GWMemoryToMemoryAnalysisAudit(void *inputBuffer, size_t inputBufferLength, wchar_t *wcType, void **analysisFileBuffer, size_t *analysisFileBufferLength)
    • int GWMemoryToMemoryProtect(void *inputBuffer, size_t inputBufferLength, const wchar_t *wcType, void **outputFileBuffer, size_t *outputLength)

    GWMemoryToMemoryAnalysisAudit

    int GWMemoryToMemoryAnalysisAudit (void * inputBuffer, size_t inputBufferLength, wchar_t * wcType, void ** analysisFileBuffer, size_t * analysisFileBufferLength)

    This function protects the specified input file buffer, returning the analysis report of the processed file to the specified memory location.

    in

    inputBuffer

    Input buffer containing the file to be processed.

    in

    inputBufferLength

    Length of the input buffer containing the file to be processed.

    in

    wcType

    wcType

    in,out

    analysisFileBuffer

    output analysis report buffer from Glasswall processing. See outputFileBuffer.

    out

    analysisFileBufferLength

    length of the outputFileBuffer that has been allocated. See outputLength.

    Returns

    Remarks

    Glasswall GWMemoryToMemoryAnalysisAudit processing example.

       // input file buffer and length
       void *inputFileBuffer	= NULL;
       size_t inputFileLength	= 0;
    
    // output analysis report buffer and length 
       void *analysisFileBuffer	= NULL;
       size_t analysisFileBufferLength = 0;
    
    // load file from disk
    if (eGwFileStatus_Success == gwLoadFileFromDisk(L"C:\\data\\temp1.pdf",
    &inputFileBuffer, &inputFileLength))
    {
       // Library configuration
       wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
       if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
       {
       if(GWMemoryToMemoryAnalysisAudit(inputFileBuffer, inputFileLength, 
    L"pdf", &analysisFileBuffer, &analysisFileBufferLength))
            {
                 // process the analysis report
            }
       }
       else
       {
            // error handling
       }
    
       // free memory allocated by gwLoadFileFromDisk 
       gwFree(inputFileBuffer);
    }
    else
    
    {
       // error handling
    }
    
       // release resources including the global buffer 'analysisFileBuffer'
       GWFileDone();

    GWMemoryToMemoryProtect

    int GWMemoryToMemoryProtect (void * inputBuffer, size_t inputBufferLength, const wchar_t * wcType, void ** outputFileBuffer, size_t * outputLength)

    This function protects the specified input file buffer, returning the managed version of the file to the specified memory location.

    Parameters

    in

    inputBuffer

    Input buffer containing the file to be processed.

    in

    inputBufferLength

    Length of the input buffer containing the file to be processed.

    in

    wcType

    wcType

    in,out

    outputFileBuffer

    output analysis report buffer from Glasswall processing. See outputFileBuffer.

    out

    analysisFileBufferLength

    length of the outputFileBuffer that has been allocated. See outputLength.

    Returns

    Remarks

    Glasswall GWMemoryToMemoryProtect processing example.

    // input file buffer and length 
    void *inputFileBuffer = NULL;
    size_t inputFileLength = 0;
    
    // managed file output buffer and length
    void *outputFileImage = NULL; 
    size_t outputFileImageLength = 0; 
    
    // load file from disk 
    if (eGwFileStatus_Success == gwLoadFileFromDisk(L"C:\\data\\temp1.pdf",
    &inputFileBuffer, &inputFileLength)) 
    {
        // Library configuration
        wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
        if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
        {
            if(GWMemoryToMemoryProtect(inputFileBuffer, inputFileLength, L"pdf",
    &outputFileImage, &outputFileImageLength))
            {
                  // process the managed file image
            }
        }
        else
        {
            // error handling 
        }
    
        // free memory allocated by gwLoadFileFromDisk
        gwFree(inputFileBuffer);
     }
     else
     {
        // error handling
     }
    
     // release resources including the global buffer 'outputFileImage'
     GWFileDone();

    Was this article helpful?