import Tabs from '@theme/Tabs'
import TabItem from '@theme/TabItem'


The **GW2RegisterExportMemory** function registers the memory location to store the exported file. Using this function
**activates** the Export Process Mode for the session.

<Tabs>

<TabItem value="C++" label="C++" default>

**Synopsis**

For session **session**, the **GW2RegisterExportMemory** function registers where the exported content is to be placed, and where to place the size in bytes of the exported content. A pointer to the exported content will be placed in the object pointed to by **exportFileBuffer** and the size in bytes of the exported data will be placed in the **size_t** object pointed to by **exportFileBufferLength**. The exported content will be deleted when the session is closed using **GW2CloseSession**. Using this function activates the Export Process Mode for the session.

```cpp

#include "glasswall.core2.api.h"
int GW2RegisterExportMemory(Session session,
                            char **exportFileBuffer,
                            size_t *exportFileBufferLength);

```

**Returns**

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

</TabItem>

<TabItem value="C#" label="C#">


**Synopsis**

```csharp
public int RegisterExportMemory(
    int session,
    out IntPtr exportFileBufferPtr,
    ref UIntPtr exportBufferLengthPtr)

```

**Returns**

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

</TabItem>

<TabItem value="Java" label="Java">

**Synopsis**

```java 
import com.glasswall.core2javabridge.*;

public int GW2RegisterExportMemory(int session) throws GlasswallException
```

**Description**

The **GW2RegisterExportMemory** function registers a memory buffer to be used as the output for the exported file, for the session specified by `session`. Call **GetExportBuffer** after having called **GW2RunSession** in order to retrieve the exported data.

**Returns**

The **GW2RegisterExportMemory** function returns a **GW2_RetStatus** enumeration converted to `int`. The value will be negative if an error occurred. `0` indicates success. Refer to the API Overview/Return types for details. 

A **GlasswallException** exception will be thrown if `session` is invalid.

**Synopsis - Retrieve Data**

```java
import com.glasswall.core2javabridge.*;

public byte[] GetExportBuffer(int session) throws GlasswallException
```

**Description**

The **GetExportBuffer** function retrieves the contents of the export buffer associated with the session specified by `session`.

**Returns**

The **GetExportBuffer** function returns a `byte[]` containing the exported file. This will be null if **GW2RegisterExportMemory** and **GW2RunSession** have not been called, or if the file is non-conforming.

A **GlasswallException** exception will be thrown if `session` is invalid.

</TabItem>

<TabItem value="Python" label="Python">

**Synopsis**

Registers a file to be exported for the given session. The export file will be created during the session's run_session call.

```py
def register_export(self, session: int, output_file: Optional[str] = None):
    """ Registers a file to be exported for the given session. The export file will be created during the session's run_session call.

    Args:
        session (int): The session integer.
        output_file (Optional[str]): Default None. The file path where the export will be written. None exports the file in memory.

    Returns:
        gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attribute 'status' indicating the result of the function call and 'session', the session integer. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.
    """
```

**Returns**

gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attribute 'status' indicating the result of the function call and 'session', the session integer. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size.

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

</TabItem>

<TabItem value="JavaScript" label="JavaScript">

**Synopsis**

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

```jsx

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

GW2RegisterExportMemory(session, exportFileBuffer, exportLength)

```

**Returns**

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

</TabItem>

</Tabs>