GW2RegisterPoliciesMemory
Ang GW2RegisterPoliciesMemory ay nagrerehistro ng XML file ng policy sa pamamahala ng nilalaman na nakaimbak sa memory sa isang session.
Kung alinman sa GW2RegisterPoliciesFile o GW2RegisterPoliciesMemory ay hindi nairehistro sa isang session, ang mga default policy ay ilalapat sa session na iyon. Itinatakda ng default policy ang lahat ng content management switch sa Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
Buod
Para sa session na session, ang function na GW2RegisterPoliciesMemory ay nagrerehistro ng mga policy na gagamitin ng Glasswall kapag nagpoproseso ng mga file. Ang policies ay isang pointer sa data ng mga policy, tinutukoy ng policiesLength ang laki sa bytes ng data ng mga policy, at tinutukoy ng policiesFormat ang format ng data ng mga policy.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesMemory(Session session,
const char *policies,
size_t policiesLength,
Policy_format format);
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.
Halimbawa
#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 */
Buod
Nagrerehistro ng mga policy na gagamitin ng Glasswall kapag nagpoproseso ng mga file
/// <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)
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.
Buod
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, NullPointerException
Tandaan
Sumangguni sa API Overview/Return types para sa mga wastong enumerator para sa format.
Ang length ng policiesBuffer ay maaaring tukuyin bilang opsyonal.
Ibinabalik
Ang function na GW2RegisterPoliciesMemory ay nagbabalik ng isang enumerasyon na GW2_RetStatus na kino-convert sa int. Magiging negatibo ang value kung may naganap na error. Ang 0 ay nagpapahiwatig ng tagumpay. Sumangguni sa API Overview/Return types para sa mga detalye.
Maghahagis ng exception na GlasswallException kung hindi wasto ang session.
Maghahagis ng exception na NullPointerException kung ang policiesBuffer ay null o walang laman.
Buod
Itinatakda ang configuration ng content management policy. Kung ang input_file ay None, ilalapat ang mga default na setting (sanitise).
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'.
"""
Ibinabalik
Isang object na may iba't ibang attribute depende sa uri ng input_file.
-
Kung ang input_file ay isang str file path:
- gw_return_object (glasswall.GwReturnObj): Isang instance ng GwReturnObj na may mga attribute na 'session', 'input_file', 'policy_format', 'status'.
-
Kung ang input_file ay isang file sa memory:
- gw_return_object (glasswall.GwReturnObj): Isang instance ng GwReturnObj na may mga attribute na 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
Ang status attribute ay isang integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng failure.
Buod
Humihiling ang function na ito na gamitin ng tinukoy na session ang mga policy na nakaimbak sa isang tinukoy na 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)
Ibinabalik
Nagbabalik ng integer na GW2_RetStatus enum value. Ang mga negatibong numero ay nagpapahiwatig ng pagkabigo.