GW2RegisterExportTextDumpMemory

Prev Next

The GW2RegisterExportTextDumpMemory function registers the memory location to store the export text dump file. Using this function **activates** the Text Dump option for the Export Process Mode for the session.

Synopsis

For session session, the GW2RegisterExportTextDumpMemory function registers where the text dump for the exported content is to be placed, and where to place the size in bytes of the text dump content. A pointer to the text dump content will be placed in the object pointed to by exportTextDumpFileBuffer and the size in bytes of the text dump data will be placed in the size_t object pointed to by exportTextDumpLength. The text dump content will be deleted when the session is closed using GW2CloseSession. Using this function activates the Text Dump option for the Export Process Mode for the session.

#include "glasswall.core2.api.h"
int GW2RegisterExportTextDumpMemory(Session session,
                            char **exportTextDumpFileBuffer,
                            size_t *exportTextDumpLength);

Returns

Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

Synopsis

public int RegisterTextDumpMemory(
    int session,
    out IntPtr textDumptFileBufferPtr,
    ref UIntPtr textDumpBufferLengthPtr)

Returns

Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

Synopsis

import com.glasswall.core2javabridge.*;

public int GW2RegisterExportTextDumpMemory(int session) throws GlasswallException

Description

The GW2RegisterExportTextDumpMemory function registers a memory buffer as the output for the exported text dump for the session specified by session. Call GetTextDumpBuffer after having called GW2RunSession in order to retrieve the exported text dump data.

Returns

The GW2RegisterExportTextDumpMemory function returns a GW2_RetStatus enumeration converted to int. The value will be negative if an error occurred. 0 indicates success.

Please refer to API Overview for Return Types and their details.

A GlasswallException exception will be thrown if session is invalid.

Synopsis - Retrieve Data

import com.glasswall.core2javabridge.*;

public byte[] GetTextDumpBuffer(int session) throws GlasswallException

Description

Retrieves the contents of the exported text dump buffer associated with the session specified by session.

Returns

Returns a byte[] containing the exported text dump. This byte array will be null if GW2RegisterExportTextDumpMemory and GW2RunSession have not been called.

A GlasswallException exception will be thrown if session is invalid.

Synopsis

Registers a memory buffer as the output for the exported text dump for the given session. The text dump will be created during the session's run_session call.

def _GW2RegisterExportTextDumpMemory(self, session: int):
    """ Registers an export text dump to be written in memory.

    Args:
        session (int): The session integer.

    Returns:
        gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.
    """

Returns

gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.

The status attribute is an integer GW2_RetStatus enum value. Negative numbers indicate a failure.

The text dump can be converted to bytes after run_session has been called using glasswall.utils.buffer_to_bytes.

Example:

import glasswall


editor = glasswall.Editor(r"<path to dir containing Glasswall libraries>")

input_file = r"<path to an input file>"

with open(input_file, "rb") as f:
    input_file_memory = f.read()

with editor.new_session() as session:
    register_input = editor._GW2RegisterInputMemory(session, input_file_memory)
    register_export = editor._GW2RegisterExportMemory(session)
    register_export_text_dump_memory = editor._GW2RegisterExportTextDumpMemory(session)
    status = editor.run_session(session)

    file_session_status = editor._GW2FileSessionStatus(session)
    file_error_message = editor._GW2FileErrorMsg(session)

    file_bytes = glasswall.utils.buffer_to_bytes(
        register_export.buffer,
        register_export.buffer_length
    )
    text_dump = glasswall.utils.buffer_to_bytes(
        register_export_text_dump_memory.buffer,
        register_export_text_dump_memory.buffer_length
    )

Synopsis

This function registers an export text dump memory location against a specified session.

/**
*
* @param {number} session The ID of the session.
* @param {string} exportTextDumpFileBuffer A pointer to the specified memory location.
* @param {number} exportTextDumpLength The size of the file buffer.
*/

GW2RegisterExportTextDumpMemory(session, exportTextDumpFileBuffer, exportTextDumpLength)

Returns

Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.