GW2RegisterExportTextDumpMemory
ฟังก์ชัน GW2RegisterExportTextDumpMemory ใช้ลงทะเบียนตำแหน่งหน่วยความจำสำหรับจัดเก็บไฟล์ export text dump การใช้ฟังก์ชันนี้จะเปิดใช้งานตัวเลือก Text Dump สำหรับ Export Process Mode ของเซสชัน
- C++
- C#
- Java
- Python
- JavaScript
สรุป
สำหรับเซสชัน session ฟังก์ชัน GW2RegisterExportTextDumpMemory จะลงทะเบียนตำแหน่งที่จะวาง text dump สำหรับเนื้อหาที่ export และตำแหน่งที่จะวางขนาดของเนื้อหา text dump เป็นไบต์ พอยน์เตอร์ไปยังเนื้อหา text dump จะถูกวางไว้ในอ็อบเจ็กต์ที่ exportTextDumpFileBuffer ชี้อยู่ และขนาดของข้อมูล text dump เป็นไบต์จะถูกวางไว้ในอ็อบเจ็กต์ size_t ที่ exportTextDumpLength ชี้อยู่ เนื้อหา text dump จะถูกลบเมื่อปิดเซสชันโดยใช้ GW2CloseSession การใช้ฟังก์ชันนี้จะเปิดใช้งานตัวเลือก Text Dump สำหรับ Export Process Mode ของเซสชัน
#include "glasswall.core2.api.h"
int GW2RegisterExportTextDumpMemory(Session session,
char **exportTextDumpFileBuffer,
size_t *exportTextDumpLength);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
public int RegisterTextDumpMemory(
int session,
out IntPtr textDumptFileBufferPtr,
ref UIntPtr textDumpBufferLengthPtr)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public int GW2RegisterExportTextDumpMemory(int session) throws GlasswallException
คำอธิบาย
ฟังก์ชัน GW2RegisterExportTextDumpMemory จะลงทะเบียนบัฟเฟอร์หน่วยความจำเป็นเอาต์พุตสำหรับ exported text dump ของเซสชันที่ระบุโดย session ให้เรียก GetTextDumpBuffer หลังจากเรียก GW2RunSession แล้ว เพื่อดึงข้อมูล exported text dump
ส่งกลับ
ฟังก์ชัน GW2RegisterExportTextDumpMemory จะส่งคืนค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบหมายความว่าเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง
เรื่องย่อ - ดึงข้อมูล
import com.glasswall.core2javabridge.*;
public byte[] GetTextDumpBuffer(int session) throws GlasswallException
คำอธิบาย
ดึงเนื้อหาของบัฟเฟอร์ exported text dump ที่เชื่อมโยงกับเซสชันที่ระบุโดย session
ส่งกลับ
ส่งคืน byte[] ที่มี exported text dump อาร์เรย์ไบต์นี้จะเป็น null หากยังไม่ได้เรียก GW2RegisterExportTextDumpMemory และ GW2RunSession
จะมีการโยนข้อยกเว้น GlasswallException หาก `session``` ไม่ถูกต้อง
สรุป
ลงทะเบียนบัฟเฟอร์หน่วยความจำเป็นเอาต์พุตสำหรับ exported text dump ของเซสชันที่กำหนด text dump จะถูกสร้างขึ้นระหว่างการเรียก run_session ของเซสชัน
def _GW2RegisterExportTextDumpMemory(self, session: int):
""" Registers an export text dump to be written in memory.
Args:
session (int): The session integer.
Returns:
gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.
"""
ส่งกลับ
gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'session', 'buffer', 'buffer_length', 'status'
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
text dump สามารถแปลงเป็น bytes ได้หลังจากมีการเรียก run_session แล้ว โดยใช้ glasswall.utils.buffer_to_bytes
ตัวอย่าง
import glasswall
editor = glasswall.Editor(r"<path to dir containing Glasswall libraries>")
input_file = r"<path to an input file>"
with open(input_file, "rb") as f:
input_file_memory = f.read()
with editor.new_session() as session:
register_input = editor._GW2RegisterInputMemory(session, input_file_memory)
register_export = editor._GW2RegisterExportMemory(session)
register_export_text_dump_memory = editor._GW2RegisterExportTextDumpMemory(session)
status = editor.run_session(session)
file_session_status = editor._GW2FileSessionStatus(session)
file_error_message = editor._GW2FileErrorMsg(session)
file_bytes = glasswall.utils.buffer_to_bytes(
register_export.buffer,
register_export.buffer_length
)
text_dump = glasswall.utils.buffer_to_bytes(
register_export_text_dump_memory.buffer,
register_export_text_dump_memory.buffer_length
)
สรุป
ฟังก์ชันนี้ลงทะเบียนตำแหน่งหน่วยความจำสำหรับ export text dump กับ session ที่ระบุ
/**
*
* @param {number} session The ID of the session.
* @param {string} exportTextDumpFileBuffer A pointer to the specified memory location.
* @param {number} exportTextDumpLength The size of the file buffer.
*/
GW2RegisterExportTextDumpMemory(session, exportTextDumpFileBuffer, exportTextDumpLength)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว