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



The **GW2RegisterImportMemory** function registers the memory location containing the interchange file required for import. The interchange file is the zip file produced from the export process and the memory location is provided by `GW2RegisterExportMemory`. Using the **GW2RegisterImportMemory** function **activates** the Import Process Mode for the session.

<Tabs>

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

```cpp
#include "glasswall.core2.api.h"
int GW2RegisterImportMemory(Session session, char *importFileBuffer, size_t *importLength);
```

**Parameters**

&emsp; **session** The ID of the session as returned by `GW2OpenSession`.

&emsp; **importFileBuffer** The memory location containing the interchange file required for import. The memory location is provided by `GW2RegisterExportMemory` and the file must conform to the interchange file format.

&emsp; **importLength** The length of `importFileBuffer` in bytes

**Returns**

&emsp; Returns an integer indicating whether the function call was successful. Negative numbers indicate a failure. See the [Return Types](/embedded-engine/embedded-engine-api-overview#return-types) table for an explanation of the return codes.

</TabItem>

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

**Synopsis**

```csharp
public int RegisterImportMemory(
    int session,
    byte[] importFileBuffer)

```

**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 GW2RegisterImportMemory(int session, byte[] importBuffer) throws GlasswallException, NullPointerException

public int GW2RegisterImportMemory(int session, byte[] importBuffer, int length) throws GlasswallException, NullPointerException
```

**Note**

Refer to API Overview/Return types for valid enumerators for ```format```.

The `length` of the `fileBuffer` may optionally be specified.

**Returns**

The **GW2RegisterImportMemory** 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, or if the import buffer could not be retrieved.

A **NullPointerException** exception will be thrown if `importBuffer` buffer is null or empty.

</TabItem>

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

**Synopsis**

Registers a .zip file to be imported for the given session. The constructed file will be created during the session's run_session call.

```py
def register_import(self, session: int, input_file: Union[str, bytes, bytearray, io.BytesIO]):
    """ Registers a .zip file to be imported for the given session. The constructed file will be created during the session's run_session call.

    Args:
        session (int): The session integer.
        input_file (Union[str, bytes, bytearray, io.BytesIO]): The input import file path or bytes.

    Returns:
        gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attribute 'status' indicating the result of the function call. 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. 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 import memory location against a specified session.

```jsx

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

GW2RegisterImportMemory(session, import_File_Buffer, import_File_Buffer_Length)

```

**Returns**

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

</TabItem>

</Tabs>