GW2RegisterPoliciesMemory
ฟังก์ชัน GW2RegisterPoliciesMemory ใช้ลงทะเบียนไฟล์ XML ของ policy การจัดการเนื้อหาที่เก็บอยู่ในหน่วยความจำเข้ากับเซสชันหนึ่ง
หากไม่มีการลงทะเบียนทั้ง GW2RegisterPoliciesFile หรือ GW2RegisterPoliciesMemory กับเซสชัน ระบบจะใช้ policies เริ่มต้นกับเซสชันนั้น policy เริ่มต้นจะตั้งค่าสวิตช์การจัดการเนื้อหาทั้งหมดเป็น Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
สรุป
สำหรับเซสชัน session ฟังก์ชัน GW2RegisterPoliciesMemory จะลงทะเบียน policies ที่ Glasswall จะใช้เมื่อประมวลผลไฟล์ โดย policies เป็นตัวชี้ไปยังข้อมูล policies, policiesLength ระบุขนาดของข้อมูล policies เป็นไบต์ และ policiesFormat ระบุรูปแบบของข้อมูล policies
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesMemory(Session session,
const char *policies,
size_t policiesLength,
Policy_format format);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
ตัวอย่าง
#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 */
สรุป
ลงทะเบียน policies ที่ Glasswall จะใช้เมื่อประมวลผลไฟล์
/// <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)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
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
หมายเหตุ
โปรดดู API Overview/Return types สำหรับ enumerator ที่ใช้ได้ของ format.
สามารถระบุ length ของ policiesBuffer ได้ตามต้องการ
ส่งกลับ
ฟังก์ชัน GW2RegisterPoliciesMemory จะส่งกลับค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบหมายความว่าเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง
ระบบจะโยนข้อยกเว้น NullPointerException หาก policiesBuffer เป็น null หรือว่างเปล่า
สรุป
ตั้งค่าคอนฟิกูเรชัน policy การจัดการเนื้อหา หาก input_file เป็น None ระบบจะใช้การตั้งค่าเริ่มต้น (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'.
"""
ส่งกลับ
อ็อบเจ็กต์ที่มีแอตทริบิวต์แตกต่างกันไปตามชนิดของ input_file
-
หาก input_file เป็นพาธไฟล์แบบ str:
- gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'session', 'input_file', 'policy_format', 'status'.
-
หาก input_file เป็นไฟล์ในหน่วยความจำ:
- gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
สรุป
ฟังก์ชันนี้ร้องขอให้เซสชันที่ระบุใช้ polices ที่จัดเก็บอยู่ในบัฟเฟอร์หน่วยความจำที่ระบุ
/**
* @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)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว