The GW2RegisterPoliciesMemory registers the content management policy XML file held in memory to a session.
If neither GW2RegisterPoliciesFile or GW2RegisterPoliciesMemory is registered with a session, the default policies will be applied to that session.
The default policy sets all content management switches to Sanitise.
Synopsis
For session session, the GW2RegisterPoliciesMemory function registers the policies to be used by Glasswall when processing files. policies is a pointer to the policies data, policiesLength specifies the size in bytes of the policies data, and policiesFormat specifies the format of the policies data.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesMemory(Session session,
const char *policies,
size_t policiesLength,
Policy_format format);Returns
Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.
Example
#include "glasswall.core2.api.h"
Session session = GW2OpenSession();
char *policies = NULL;
size_t size = 0;
if (!session)
/* deal with error */
else
{
/* ... load 'policies' with a pointer to the policies content ... */
if (GW2RegisterPoliciesMemory(session, policies, size, PF_XML) < 0)
/* deal with error */
else
/* continue processing */
}
. . .
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */Synopsis
Registers the policies to be used by Glasswall when processing files.
/// <param name="session">Session ID number</param>
/// <param name="policies">The policy file</param>
/// <param name="policiesFormat">Format of the policies data</param>
public int RegisterPoliciesMemory(
int session,
byte[] policies,
int policiesFormat)Returns
Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.
Synopsis
import com.glasswall.core2javabridge.*;
public int GW2RegisterPoliciesMemory(int session, byte[] policiesBuffer, int format) throws GlasswallException, NullPointerException
public int GW2RegisterPoliciesMemory(int session, byte[] policiesBuffer, int length, int format) throws GlasswallException, NullPointerExceptionNote:
Please refer to API Overview for Return Types and valid enumerators for format.
The length of the policiesBuffer may optionally be specified.
Returns
The GW2RegisterPoliciesMemory 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 policiesBuffer is null or empty.
Synopsis
Sets the content management policy configuration. If input_file is None then default settings (sanitise) are applied.
def set_content_management_policy(self, session: int, input_file: Union[None, str, bytes, bytearray, io.BytesIO, "glasswall.content_management.policies.policy.Policy"] = None, policy_format=0):
""" Sets the content management policy configuration. If input_file is None then default settings (sanitise) are applied.
Args:
session (int): The session integer.
input_file (Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional): Default None (sanitise). The content management policy to apply.
policy_format (int): The format of the content management policy. 0=XML.
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', 'policy_format', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', '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', 'policy_format', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
The status attribute is an integer GW2_RetStatus enum value. Negative numbers indicate a failure.
Synopsis
This function requests that the specified session uses the polices stored in a specified memory buffer.
/**
* @param {number} session The ID of the session.
* @param {string} policies A pointer to the policy data buffer.
* @param {number} policiesLength The length of the data in the policy buffer.
* @param {number} format The format of the policy.
*/
GW2RegisterPoliciesMemory(
session,
policies,
policyLength,
format)Returns
Returns an integer GW2_RetStatus enum value. Negative numbers indicate a failure.