GW2GetPolicySettings
ฟังก์ชัน GW2GetPolicySettings ให้สตริงที่สอดคล้องกับเนื้อหาของไฟล์การตั้งค่า policy ที่เชื่อมโยงกับ session ที่ระบุ
- C++
- C#
- Java
- Python
- JavaScript
#include "glasswall.core2.api.h"
int GW2GetPolicySettings (
Session session,
char **policiesBuffer,
size_t *policiesLength,
Policy_format format);
พารามิเตอร์
session ID ของ session ตามที่ส่งกลับโดย GW2OpenSession
policiesBuffer พารามิเตอร์เอาต์พุตแบบตัวชี้สตริง ซึ่งจะถูกเติมด้วยข้อมูลการตั้งค่า policy หน่วยความจำที่ใช้โดยตัวชี้นี้ไม่จำเป็นต้องถูก free โดยผู้ใช้ ในกรณีที่ล้มเหลว พารามิเตอร์นี้อาจถูกตั้งค่าเป็น nullptr
policiesLength พารามิเตอร์เอาต์พุตซึ่งจะถูกเติมด้วยขนาดเป็นไบต์ของหน่วยความจำที่ policiesBuffer ชี้ไป
format รูปแบบของข้อมูล ต้องเป็น PF_XML
ส่งกลับ
ส่งกลับจำนวนเต็มที่ระบุว่าการเรียกใช้ฟังก์ชันสำเร็จหรือไม่ ตัวเลขติดลบบ่งชี้ถึงความล้มเหลว ดูตาราง Return Types สำหรับคำอธิบายของรหัสส่งกลับ
สรุป
/// <summary>
/// Retrieves policy settings for the session
/// </summary>
/// <param name="session">Current open Glasswall session</param>
/// <param name="policiesBufferPtr">A pointer to the object containing a pointer pointing to the policy data</param>
/// <param name="policiesLengthPtr">A pointer to a object containing the size in bytes </param>
public int GetPolicySettings(
int session,
out IntPtr policiesBufferPtr,
ref UIntPtr policiesLengthPtr,
int format)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public String GW2GetPolicySettingsString(int session, int format) throws GlasswallException
หมายเหตุ
ฟังก์ชัน GW2GetPolicySettingsString จะแสดงผลการตั้งค่า policy ที่ลงทะเบียนอยู่ในปัจจุบันสำหรับเซสชันที่ระบุโดย session.
โปรดดู API Overview/Return types สำหรับ enumerator ที่ใช้ได้ของ format.
ก่อนหน้านี้ความสามารถนี้ต้องใช้การเรียกฟังก์ชันแยกกันสองครั้งเพื่อดึงข้อมูลการตั้งค่า policy ขณะนี้ได้ปรับให้เรียบง่ายขึ้นโดยส่งคืนการตั้งค่าเป็น String แล้ว ฟังก์ชันดั้งเดิมทั้งสองถูกเลิกใช้งานแล้ว.
ส่งกลับ
ฟังก์ชัน GW2GetPolicySettingsString จะส่งคืน String ที่มีการตั้งค่า policy.
จะมีการโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงการตั้งค่า policy ได้.
สรุป - ฟังก์ชันที่เลิกใช้แล้ว
import com.glasswall.core2javabridge.*;
(Deprecated)
public int GW2GetPolicySettings(int session, int format) throws GlasswallException
public byte[] GetPolicyBuffer(int session) throws GlasswallException
คำอธิบาย - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetPolicySettings จะแสดงผลการตั้งค่า policy ที่ลงทะเบียนอยู่ในปัจจุบันสำหรับเซสชันที่ระบุโดย session ไปยังบัฟเฟอร์ policy ภายใน ดึงข้อมูลนี้ได้โดยใช้ฟังก์ชัน GetPolicyBuffer.
โปรดดู API Overview/Return types สำหรับ enumerator ที่ใช้ได้ของ format.
ค่าที่ส่งกลับ - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetPolicySettings จะส่งคืนค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบหมายความว่าเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types.
GetPolicyBuffer จะส่งคืน byte[] ที่มีการตั้งค่า policy โดยค่าจะเป็น null หากยังไม่ได้เรียก GW2GetPolicySettings.
จะมีการโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงการตั้งค่า policy ได้.
สรุป
ส่งคืนการกำหนดค่าการจัดการเนื้อหาสำหรับเซสชันที่กำหนด.
def get_content_management_policy(self, session: int):
""" Returns the content management configuration for a given session.
Args:
session (int): The session integer.
Returns:
xml_string (str): The XML string of the current content management configuration.
"""
ส่งกลับ
xml_string (str): สตริง XML ของการกำหนดค่าการจัดการเนื้อหาปัจจุบัน
สรุป
/**
* This function returns the policy settings used for the specified session
*
* @param {number} session The ID of the session.
* @param {string} policiesBuffer The pointer to the policy buffer.
* @param {number} policiesLength The size of the data in the policy buffer
* @param {number} format The format of the policy.
*/
GW2GetPolicySettings(
session,
policiesBuffer,
policiesLength,
format)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
ตัวอย่าง
const ref = require('ref-napi');
...
function buffer_to_string(buffer, buffer_size) {
if (!buffer.isNull() && ref.deref(buffer_size) > 0) {
return Buffer.from(ref.reinterpret(ref.deref(buffer), ref.deref(buffer_size), 0)).toString();
}
else {
return "";
}
}
...
let policy_file_buffer = ref.alloc(ref.refType(ref.types.CString));
let policy_buffer_size = ref.alloc(ref.types.size_t, 0);
let return_status = gw.GW2GetPolicySettings(session_id, policy_file_buffer, policy_buffer_size, 0);
let xml_string = buffer_to_string(policy_file_buffer, policy_buffer_size);
...