GW2RegisterLicenceMemory
    • PDF

    GW2RegisterLicenceMemory

    • PDF

    Article Summary

    The GW2RegisterLicenceMemory registers the licence file held in memory to a session.

    If neither GW2RegisterLicenceFile or GW2RegisterLicenceMemory is registered with a session, the Editor will attempt to search for the licence in the default location. This is a file called gwkey.lic located in the same folder as the Editor library. If that cannot be found then the library will be considered unlicenced and some processes may fail with licence expiry issues.

    Synopsis

    For session session, the GW2RegisterLicenceMemory function registers the licence to be used by Glasswall when processing files. licenceContents is a pointer to the licence data, licenceLength specifies the size in bytes of the licence data.

    #include "glasswall.core2.api.h"
        int GW2RegisterLicenceMemory(Session session, 
                                     const char *licenceContents, 
                                     size_t licenceLength);

    Returns

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

    Example

     #include "glasswall.core2.api.h"
    
        Session session = GW2OpenSession();
        char *licence = NULL;
        size_t size = 0;
        if (!session)
            /* deal with error */
        else
        {
            /* ... load 'licence' with a pointer to the licence content ... */
            if (GW2RegisterLicenceMemory(session, licence, size) < 0)
                /* deal with error */
            else
                /* continue processing */
        }
    
        . . .
    
        /* later */
        if (GW2CloseSession(session) < 0)
            /* error closing session */

    Synopsis

    For session session, the RegisterLicenceMemory method registers the licence to be used by Glasswall when processing files.

    /// <summary>
            /// Provide a licence to use for the session.
            /// </summary>
            /// <param name="session">Current open Glasswall session</param>
            /// <param name="licence">Byte content of the licence</param>
            public int RegisterLicenceMemory(int session, byte[] licence)

    Returns

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

    Synopsis

    For session session, the GW2RegisterLicenceMemory function registers the licence to be used by Glasswall when processing files. BYTE is a pointer to the licence data, licenceLength specifies the size in bytes of the licence data.

    import com.glasswall.core2javabridge.*;
    
    public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer) throws GlasswallException, NullPointerException
    
    public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer, int licenceLength) throws GlasswallException, NullPointerException

    Note:

    The length of the licenceBuffer may optionally be specified.

    Returns

    The GW2RegisterLicenceMemory 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.

    A NullPointerException exception will be thrown if licenceBuffer buffer is null or empty.

    Not supported in Python.

    A licence file should be present in the directory that contains the Glasswall Editor library.

    Returns

    status (int): The result of the Glasswall API call.

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

    Synopsis

    For session session, the GW2RegisterLicenceMemory function registers the licence to be used by Glasswall when processing files. licenceContents is a pointer to the licence data, licenceLength specifies the size in bytes of the licence data.

     /**
         * Provides the contents of the licence file that will be used for this session.
         * @param {number} session The ID of the session.
         * @param {string} licenceContents A pointer to the licence data buffer.
         * @param {number} licenceLength Length of the data in the licence buffer.
         * @returns {number} Status of the operation; 0 for success, non-zero for failure.
         */
        GW2RegisterLicenceMemory(session, licenceContents, licenceLength)

    Returns

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


    Was this article helpful?