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


The **GW2RegisterInputFile** function registers a path to the file to be processed in a session.

<Tabs>

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

**Synopsis**

The **GW2RegisterInputFile** function registers the file to be processed in session **session**. The file name is the string pointed to by **inputFilePath**.

```cpp
#include "glasswall.core2.api.h"
int GW2RegisterInputFile(Session session, const char *inputFilePath);
```

**Returns**

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


**Example**

```cpp

#include "glasswall.core2.api.h"

HANDLE session = GW2OpenSession();
if (!session)
    /* deal with error */
else
{
    if (GW2RegisterInputFile(session, "filename.doc") < 0)
        /* deal with error */
    else
        /* continue processing */
        ...
}

/* later */
if (GW2CloseSession(session) < 0)
    /* error closing session */

```

</TabItem>

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

**Synopsis**

```csharp
public int RegisterInputFile(
    int session,
    string inputFilePath)

```

**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 GW2RegisterInputFile(int session, String inputFilePath) throws GlasswallException, NullPointerException

(Deprecated)
public int GW2RegisterInputFile(int session, byte[] inputFilePath) throws GlasswallException, NullPointerException
```

**Note**

The **GW2RegisterInputFile** function parameters have been updated to use `String` in place of `byte[]`. The original function has been deprecated.

**Returns**

The **GW2RegisterInputFile** 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 **NullPointerException** exception will be thrown if `inputFilePath` is null or empty.

A **GlasswallException** exception will be thrown if `session` is invalid, if the `inputFilePath` could not be retrieved, or if the `inputFilePath` could not be converted to UTF-8.

</TabItem>

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

**Synopsis**

Register an input file or bytes for the given session.

```py
def register_input(self, session: int, input_file: Union[str, bytes, bytearray, io.BytesIO]):
    """ Register an input file or bytes for the given session.

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

    Returns:
        - result (glasswall.GwReturnObj): Depending on the input 'input_file':
            - If input_file is a str file path:
                - gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.

            - If input_file is a file in memory:
                - gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.
    """
```

**Returns**

An object with different attributes depending on the type of `input_file`.

- If input_file is a str file path:
    - gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'input_file', 'status'.
- If input_file is a file in memory:
  - 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.

</TabItem>

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

**Synopsis**

This function registers a specified file as the input file for a specified session

```jsx

/**
 *
 * @param {number} session The ID of the session.
 * @param {string} inputFilePath The path of the file to be registered
 */

GW2RegisterInputFile(session, inputFilePath)

```

**Returns**

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

</TabItem>

</Tabs>