GW2RegisterInputMemory
ฟังก์ชัน GW2RegisterInputMemory ใช้ลงทะเบียนไฟล์อินพุตที่จัดเก็บอยู่ในหน่วยความจำกับเซสชัน
- C++
- C#
- Java
- Python
- JavaScript
สรุป
ฟังก์ชัน GW2RegisterInputMemory ใช้ลงทะเบียนไฟล์ที่จัดเก็บอยู่ในบัฟเฟอร์ที่ inputFileBuffer ชี้ไป ซึ่งมีขนาด inputLength ไบต์ กับเซสชันที่ระบุโดย session.
#include "glasswall.core2.api.h"
int GW2RegisterInputMemory(Session session, const char *inputFileBuffer, size_t inputLength);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
ตัวอย่าง
#include "glasswall.core2.api.h"
...
HANDLE session = GW2OpenSession();
if (!session)
/* deal with error */
else
{
/* ... load file contents into buffer 'buf' and log the file size in 'size' ... */
if (GW2RegisterInputMemory(session, buf, size))
/* deal with error */
else
/* continue processing */
...
}
/* later */
if (GW2CloseSession(session))
/* error closing session */
สรุป
public int RegisterInputMemory(
int session,
byte[] inputFileBuffer)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว
สรุป
import com.glasswall.core2javabridge.*;
public int GW2RegisterInputMemory(int session, byte[] inputFileBuffer) throws GlasswallException, NullPointerException
public int GW2RegisterInputMemory(int session, byte[] inputFileBuffer, int length) throws GlasswallException, NullPointerException
หมายเหตุ
สามารถระบุ length ของ inputFileBuffer ได้ตามต้องการ
ส่งกลับ
ฟังก์ชัน GW2RegisterInputMemory จะส่งกลับค่า enumeration GW2_RetStatus ที่แปลงเป็น int ค่าจะเป็นค่าติดลบหากเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
ระบบจะโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงข้อมูลบัฟเฟอร์อินพุตได้
ระบบจะโยนข้อยกเว้น NullPointerException หากบัฟเฟอร์ inputFileBuffer เป็น null หรือว่างเปล่า
สรุป
ลงทะเบียนไฟล์อินพุตหรือไบต์สำหรับ session ที่กำหนด
def register_input(self, session: int, input_file: Union[str, bytes, bytearray, io.BytesIO]):
""" Register an input file or bytes for the given session.
Args:
session (int): The session integer.
input_file (Union[str, bytes, bytearray, io.BytesIO]): The input file path or bytes.
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', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'status'.
"""
ส่งกลับ
อ็อบเจ็กต์ที่มีแอตทริบิวต์แตกต่างกันไปตามชนิดของ input_file
- If input_file is a str file path:
- gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ของ GwReturnObj ที่มีแอตทริบิวต์ 'session', 'input_file', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): อินสแตนซ์ GwReturnObj ที่มีแอตทริบิวต์ 'session', 'buffer', 'buffer_length', 'status'
แอตทริบิวต์ status เป็นค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงความล้มเหลว
สรุป
ฟังก์ชันนี้ใช้ลงทะเบียนไฟล์ที่จัดเก็บอยู่ในหน่วยความจำเป็นไฟล์อินพุตสำหรับเซสชันที่ระบุ
/**
* @param {number} session The ID of the session.
* @param {string} inputFileBuffer A buffer holding the file data
* @param {number} inputLength The size of the file buffer
*/
GW2RegisterInputMemory(session, inputFileBuffer, inputLength)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ตัวเลขติดลบหมายถึงล้มเหลว