GW2RegisterPoliciesFile
GW2RegisterPoliciesFile ใช้ลงทะเบียนไฟล์ XML ของ policy การจัดการเนื้อหาเข้ากับเซสชัน
หากไม่มีการลงทะเบียนทั้ง GW2RegisterPoliciesFile หรือ GW2RegisterPoliciesMemory กับเซสชัน ระบบจะใช้ policies เริ่มต้นกับเซสชันนั้น policy เริ่มต้นจะตั้งค่าสวิตช์การจัดการเนื้อหาทั้งหมดเป็น Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
สรุป
ฟังก์ชัน GW2RegisterPoliciesFile ร้องขอให้ session ใช้ policies ที่ระบุไว้ในไฟล์ซึ่งมีชื่อเป็นสตริงที่ filename. ชี้อยู่ รูปแบบของ policies จะเป็นไปตามรูปแบบที่ระบุโดย format policies จะถูกนำไปใช้กับการประมวลผลทั้งหมดที่ Glasswall ดำเนินการสำหรับเซสชันนั้น.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesFile(Session session, const char *filename, Policy_format format);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
ตัวอย่าง
#include "glasswall.core2.api.h"
HANDLE session = GW2OpenSession();
if (!session)
/* deal with error */
else
if (GW2RegisterPoliciesFile(session, "Office_Binary_Policies.xml", PF_XML) < 0)
/* deal with error */
else
/* the file has been successfully registered */
...
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
สรุป
ลงทะเบียนกับเซสชันที่อ้างถึงโดย session โดยใช้ไฟล์ที่ policiesFilePath ชี้อยู่ พร้อมรูปแบบที่ระบุโดย policiesFormat
/// <param name="session">ID number for the session</param>
/// <param name="policiesFilePath">The file path to the file to be processed</param>
/// <param name="policiesFormat">Format of the policy file</param>
public int RegisterPoliciesFile(
int session,
string policiesFilePath,
int policiesFormat
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public int GW2RegisterPoliciesFile(int session, String policiesFilePath, int format) throws GlasswallException, NullPointerException
(Deprecated)
public int GW2RegisterPoliciesFile(int session, byte[] policiesFilePath, int format) throws GlasswallException, NullPointerException
คำอธิบาย
โปรดดู API Overview/Return types สำหรับ enumerator ที่ใช้ได้ของ format.
พารามิเตอร์ของฟังก์ชัน GW2RegisterPoliciesFile ได้รับการอัปเดตให้ใช้ String แทน byte[] แล้ว ฟังก์ชันดั้งเดิมถูกเลิกใช้งานแล้ว
ส่งกลับ
ฟังก์ชัน GW2RegisterPoliciesFile จะส่งคืนค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าจะเป็นค่าติดลบหากเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
ระบบจะโยนข้อยกเว้น NullPointerException หาก policiesFilePath เป็น null หรือว่างเปล่า
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หากไม่สามารถดึง policiesFilePath ได้ หรือหากไม่สามารถแปลง policiesFilePath เป็น UTF-8 ได้
สรุป
ตั้งค่าคอนฟิกูเรชัน 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 แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
สรุป
ฟังก์ชันนี้ร้องขอให้ session ที่ระบุใช้ policy ในไฟล์ที่ระบุ
/**
* @param {number} session The ID of the session.
* @param {string} filename The filename from which to load policy settings.
* @param {number} format - The format of the policy to be registered.
*/
GW2RegisterPoliciesFile(
session,
filename,
format)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว