Glasswall Document Processing - File to Memory Location
    • PDF

    Glasswall Document Processing - File to Memory Location

    • PDF

    Article summary

    These functions process the specified document 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 managed 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 GWFileAnalysisAudit (wchar_t *inputFilePathName, wchar_t *wcType, void**analysisFileBuffer, size_t *analysisFileBufferLength)
    • int GWFileAnalysisAuditAndReport(wchar_t *inputFilePathName, wchar_t *wcType, void**analysisFileBuffer, size_t *analysisFileBufferLength, void **reportFileBuffer, size_t*reportFileBufferLength)
    • int GWFileProtect (const wchar_t *inputFilePathName, const wchar_t *wcType, void**outputFileBuffer, size_t *outputLength)
    • int GWFileProtectAndReport (wchar_t *inputFilePathName, wchar_t *wcType, void**outputFileBuffer, size_t *outputLength, void **reportFileBuffer, size_t*reportFileBufferLength)
    • int GWFileProtectLite (wchar_t *inputFilePathName, wchar_t *wcType, void **outputFileBuffer, size_t *outputLength)
    • int GWFileProtectLiteAndReport (wchar_t *inputFilePathName, wchar_t *wcType, void**outputFileBuffer, size_t *outputLength, void **reportFileBuffer, size_t*reportFileBufferLength)
    • int GWFileToMemoryAnalysisProtectAndExport (const wchar_t *inputFilePathName, void**outputFileBuffer, size_t *outputLength)
    • int GWFileToMemoryProtectAndImport (const wchar_t *inputFilePathName, void**outputFileBuffer, size_t *outputLength)

    GWFileAnalysisAudit

    int GWFileAnalysisAudit (wchar_t * inputFilePathName, wchar_t * wcType, void ** analysisFileBuffer, size_t * analysisFileBufferLength)

    This function carries out an Analysis Audit on the specified file returning the analysis report to the specified memory location.

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    out

    analysisFileBuffer

    analysis (XML) file buffer from Glasswall processing.

    out

    analysisFileBufferLength

    length of the analysisFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileAnalysisAudit processing example.

    // analysis file image buffer and length
    void *analysisFileImage	= NULL;
    size_t analysisFileImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if(eGwFileStatus_Success == GWFileAnalysisAudit(L"C:\\data\\temp1.pdf",
    L"pdf", &analysisFileImage, &analysisFileImageLength))
        {
            // process the analysis image
        }
    }
    
    // release resources including global buffer 'analysisFileImage' 
    GWFileDone();

    GWFileAnalysisAuditAndReport

    int GWFileAnalysisAuditAndReport (wchar_t * inputFilePathName, wchar_t * wcType, void ** analysisFileBuffer, size_t * analysisFileBufferLength, void ** reportFileBuffer, size_t * reportFileBufferLength)

    This function carries out an Analysis Audit on the specified file and produces a detailed report of the processing carried out, saving both outputs to the specified memory locations

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    out

    analysisFileBuffer

    analysis (XML) file buffer from Glasswall processing.

    out

    analysisFileBufferLength

    length of the analysisFileBuffer that has been allocated.

    out

    reportFileBuffer

    detailed report file buffer from Glasswall processing.

    out

    reportFileBufferLength

    length of the reportFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileAnalysisAuditAndReport processing example.

    // analysis file image buffer and length 
    void *analysisFileImage        = NULL; 
    size_t analysisFileImageLength = 0;
    
    void *fileReportImage	        = NULL;
    size_t fileReportImageLength	= 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if(eGwFileStatus_Success == 
    GWFileAnalysisAuditAndReport(L"C:\\data\\temp1.pdf", L"pdf", 
    &analysisFileImage, &analysisFileImageLength,
    
    &fileReportImage, &fileReportImageLength))
        {
            // process the analysis image
            // process the report image
        }
    }
    
    // release resources including global buffers 'analysisFileImageLength' and
    'fileReportImage'
    GWFileDone();

    GWFileProtect

    int GWFileProtect (const wchar_t * inputFilePathName, const wchar_t * wcType, void ** outputFileBuffer, size_t * outputLength)

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

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    in,out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileProtect processing example.

    // managed file output buffer and length 
    void *fileImage        = NULL;
    size_t fileImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if(GWFileProtect(L"C:\\data\\temp1.pdf", L"pdf", &fileImage, 
    &fileImageLength))
        {
            // process the managed file image
        }
    }
    else
    {
        // error handling
    }
    
    // release resources including the global buffer 'fileImage' 
    GWFileDone();

    GWFileProtectAndReport

    int GWFileProtectAndReport (wchar_t * inputFilePathName, wchar_t * wcType, void ** outputFileBuffer, size_t * outputLength, void ** reportFileBuffer, size_t * reportFileBufferLength)

    This function protects the specified input file, returning the managed version of the file and a detailed report of the processing done on the file to the specified memory locations.

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    out

    reportFileBuffer

    detailed report file buffer from Glasswall processing.

    out

    eportFileBufferLength

    length of the reportFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileProtectAndReport processing example This example sets the Glasswall configuration then manages the specified file using GWFileProtectAndReport ().

    // managed file output buffer and length 
    void *fileImage          = NULL;
    size_t fileImageLength	  = 0; 
    void *reportImage	  = NULL; 
    size_t reportImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
    if( eGwFileStatus_Success == GWFileProtectAndReport(L"C:\\data\\temp1.pdf", 
    L"pdf", &fileImage, &fileImageLength,
    
    &reportImage, &reportImageLength )
        {
            // process the managed file image
            // process the report image
        }
    }
    else
    {
        // error handling
    }
    
    // release resources including global buffers 'fileImage' and 'fileReportImage' 
    GWFileDone();

    GWFileProtectLite

    int GWFileProtectLite (wchar_t * inputFilePathName, wchar_t * wcType, void ** outputFileBuffer, size_t * outputLength)

    This function is a restricted version of GWFileProtect

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

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    in,out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileProtectLite processing example.

    // managed file output buffer and length 
    void *fileImage        = NULL;
    size_t fileImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if(eGwFileStatus_Success == GWFileProtectLite(L"C:\\data\\temp1.pdf", 
    L"pdf", &fileImage, &fileImageLength))
        {
            // process the managed file image   
        }
    }
    else
    {
        // error handling
    }
    
    // release resources including the global buffer 'fileImage' 
    GWFileDone();

    GWFileProtectLiteAndReport

    int GWFileProtectLiteAndReport (wchar_t * inputFilePathName, wchar_t * wcType, void ** outputFileBuffer, size_t * outputLength, void ** reportFileBuffer, size_t * reportFileBufferLength)

    This function is a restricted version of GWFileProtectAndReport.

    This function protects the specified input file, returning the managed version of the file and a detailed report of the processing done on the file to the specified memory locations.

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    in

    wcType

    file data type

    out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    out

    reportFileBuffer

    detailed report file buffer from Glasswall processing.

    out

    reportFileBufferLength

    length of the reportFileBuffer that has been allocated.

    Returns

    Remarks

    Glasswall GWFileProtectLiteAndReport processing example. This example sets the Glasswall configuration then manages the specified file using GWFileProtectLiteAndReport().

    // managed file output buffer and length 
    void *fileImage          = NULL; 
    size_t fileImageLength   = 0; 
    void *reportImage        = NULL; 
    size_t reportImageLength = 0; 
    
    // Library configuration 
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
     
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy)) 
    {
        if( eGwFileStatus_Success == GWFileProtectAndReport(L"C:\\data\\temp1.pdf", 
    L"pdf", &fileImage, &fileImageLength, 
    
    &reportImage, &reportImageLength )
       { 
            // process the managed file image
            // process the report image
       }
    }
    else 
    { 
        // error handling 
    }
    // release resources including global buffers 'fileImage' and 'fileReportImage' 
    GWFileDone();

    GWFileToMemoryAnalysisProtectAndExport

    int GWFileToMemoryAnalysisProtectAndExport (const wchar_t * inputFilePathName, void ** outputFileBuffer, size_t * outputLength)

    This function manages the specified file, carries out an Analysis Audit, extracts any text and image content which can be isolated, and returns the results in a block of memory owned and allocated by the Glasswall DLL.

    The output file will be a zip archive containing the following:

    • Glasswall XML analysis extended to include additional information and metadata which can be used to identify a particular item of image or text data within the export package and identify its point of origin within the original document for re-insertion after further processing if required. Note: Re-insertion is currently only supported for image files.
    • The managed file.
    • The extracted image and/or text data with each item taking the form of a separate file within the zip archive.

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    Returns

    Attention

    The memory buffer holding the output file image is allocated and owned by the Glasswall library. Input file type will be automatically detected.

    Remarks

    Glasswall GWFileToMemoryAnalysisProtectAndExport processing example.

    // managed file output buffer and length
    void *fileImage        = NULL;
    size_t fileImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy = getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if (eGwFileStatus_Success == 
    GWFileToMemoryAnalysisProtectAndExport(L"C:\\data\\temp1.pdf", &fileImage, 
    &fileImageLength))
        {
            // extract content of output package
            // process managed file if it was managed successfully
            // process analysis file
            // Process exported content files
        }
    }
    else
    {
        error handling
    }

    GWFileToMemoryProtectAndImport

    int GWFileToMemoryProtectAndImport (const wchar_t * inputFilePathName, void ** outputFileBuffer, size_t * outputLength)

    This function takes a file in the form of a zip archive originally generated by GWFileToFileAnalysisProtectAndExport, extracts the managed file, the XML analysis file, and externally validated (and if neccessary and/or appropriate reconstructed) image data and uses the metadata encoded into the analysis file to regenerate the managed file replacing the original image content replaced with the externally processed versions. The regenerated file is returned in the form of a block of memory allocated and owned by the Glasswall DLL.

    Parameters

    in

    inputFilePathName

    input file path for Glasswall processing.

    out

    outputFileBuffer

    output file buffer from Glasswall processing.

    out

    outputLength

    length of the outputFileBuffer that has been allocated.

    Returns

    Attention

    The memory buffer holding the output file image is allocated and owned by the Glasswall library.

    Remarks

    Glasswall GWFileToMemoryProtectAndImport processing example.

    // managed file output buffer and length 
    void *fileImage        = NULL;
    size_t fileImageLength = 0;
    
    // Library configuration
    wchar_t* cmPolicy	= getClientApplicationConfigurationXML();
    
    if (eGwFileStatus_Success == GWFileConfigXML(cmPolicy))
    {
        if(eGwFileStatus_Success == 
    GWFileToMemoryProtectAndImport(L"C:\\data\\output\\import1.zip", &fileImage, 
    &fileImageLength))
        {
            // process output file
        }
        else
        {
            // error handling
        }
    }
    else
    {
        // error handling
    }

    Was this article helpful?