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



The **GW2RegisterAnalysisFile** registers the location to store a analysis report on disk to a Session. Using this
function activates the Analysis Process for the *Session*.


<Tabs>

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

**Synopsis**

The **GW2RegisterAnalysisFile** function stores in the file whose name
is pointed to by string **analysisFilePath** the analysis report
produced by a successful run of API function **runSession** that used
session **session**. Using this function activates the Analysis Process
Mode for the session.

```cpp
#include "glasswall.core2.api.h"
int GW2RegisterAnalysisFile(Session session,
                            const char *analysisFilePath,
                            Analysis_format format);
```

**Returns**

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


**Example**

```cpp

    #include "glasswall.core2.api.h"

    Session session = GW2OpenSession();
    if (!session)
        /* deal with error */
    else
        if (GW2RegisterAnalysisFile(session, "c:\\analysis_files\\analysis_file_023.xml", AF_XML) < 0)
            /* deal with error */
        else
            /* analysis file registered */

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

```

</TabItem>

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

**Synopsis**

```csharp
public int RegisterAnalysisFile(
    int session,
    string analysisFilePath,
    int analysisFormat)

```

**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 GW2RegisterAnalysisFile(int session, String analysisFilePath, int format) throws GlasswallException, NullPointerException

(Deprecated)
public int GW2RegisterAnalysisFile(int session, byte[] analysisFilePath, int format) throws GlasswallException, NullPointerException
```

**Note**

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

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

**Returns**

The **GW2RegisterAnalysisFile** 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 `analysisFilePath` is null or empty.

A **GlasswallException** exception will be thrown if `session` is invalid, or if the `analysisFilePath` could not be retrieved.

</TabItem>

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

**Synopsis**

Registers an analysis file for the given session. The analysis file will be created during the session's run_session call.

```py
def register_analysis(self, session: int, output_file: Optional[str] = None):
    """ Registers an analysis file for the given session. The analysis 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 analysis will be written. None returns the analysis as bytes.

    Returns:
        gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'status', 'session', 'analysis_format'. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size. If output_file is not None (file mode) 'output_file' is included.
    """
```

**Returns**

gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'status', 'session', 'analysis_format'. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size. If output_file is not None (file mode) 'output_file' is included.

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 with a specified session, in line with a specified format

```jsx

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

GW2RegisterAnalysisFile(
    session,
    analysisFilePathName,
    format)

```

**Returns**

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

</TabItem>

</Tabs>