GW2GetAllIdInfo
ทุกปัญหาที่ระบุและรายงานโดย Glasswall engine จะมี issue ID เฉพาะกำกับอยู่ API นี้ให้ข้อมูลสรุปของหมายเลข issue ID ที่เป็นไปได้ทั้งหมดและคำอธิบายระดับสูงที่สอดคล้องกัน
สำหรับ session ฟังก์ชัน GW2GetAllIdInfo จะวางข้อมูล XML ที่เติมด้วยคำอธิบาย Glasswall Issue ID และช่วงค่าต่าง ๆ ลงในบัฟเฟอร์เอาต์พุต
- C++
- C#
- Java
- Python
- JavaScript
สรุป
สำหรับ session session ฟังก์ชัน GW2GetAllIdInfo จะวางตัวชี้ไปยังข้อมูล XML ที่เติมด้วยคำอธิบาย Glasswall Issue ID และช่วงค่าต่าง ๆ ไว้ในอ็อบเจ็กต์ที่ outputBuffer ชี้อยู่ ความยาวเป็นไบต์ของบัฟเฟอร์เอาต์พุตที่ถูกเติมข้อมูลแล้วจะถูกวางไว้ในอ็อบเจ็กต์ size_t ที่ bufferLength ชี้อยู่
#include "glasswall.core2.api.h"
int GW2GetAllIdInfo(
Session session,
size_t *bufferLength,
char **outputBuffer);
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ค่าติดลบหมายถึงความล้มเหลว หากสำเร็จ บัฟเฟอร์เอาต์พุตจะมีไฟล์ XML
ตัวอย่าง
#include "glasswall.core2.api.h"
...
char *outbuf = NULL;
size_t buflen = 0;
if (GW2OpenSession())
/* error opening session*/
else
{
int status = GW2GetAllIdInfo(session, &buflen, &outbuf);
/* Buffer contains the XML file.
* Either process the data pointed to, or copy the data and process it
* after the session is closed
*/
if (GW2CloseSession())
/* error closing session */
}
สรุป
public int GetAllIdInfo(
int session,
ref UIntPtr bufferLength,
out IntPtr outputBuffer)
ส่งกลับ
ส่งกลับค่า enum GW2_RetStatus แบบจำนวนเต็ม ค่าติดลบหมายถึงความล้มเหลว หากสำเร็จ บัฟเฟอร์เอาต์พุตจะมีไฟล์ XML
ตัวอย่าง
...
UIntPtr bufferLength = UIntPtr.Zero;
IntPtr buffer = new IntPtr();
int session = glasswall.OpenSession();
int returnStatus = glasswall.GetAllIdInfo(session, ref bufferLength, out buffer);
using (StreamWriter writer = new StreamWriter(fileStream))
{
writer.WriteLine($"GW2GetAllIdInfo completed with status code {returnStatus}");
if ((int)bufferLength != 0)
{
WriteBytesToFile(Path.Combine(di.FullName, $"22 - GW2GetAllIdInfo.xml"),
glasswall.CreateArrayFromBuffer(buffer, bufferLength)
);
}
}
import com.glasswall.core2javabridge.*;
public String GW2GetAllIdInfoString(int session) throws GlasswallException
หมายเหตุ
ก่อนหน้านี้ ฟังก์ชันนี้ต้องใช้การเรียกใช้ฟังก์ชันแยกกันสองครั้งเพื่อดึงข้อมูล ID ขณะนี้ได้ปรับให้เรียบง่ายขึ้นโดยส่งคืนการตั้งค่าเป็น String แล้ว ฟังก์ชันดั้งเดิมทั้งสองรายการถูกเลิกใช้แล้ว
ส่งกลับ
ฟังก์ชัน GW2GetAllIdInfoString จะส่งคืน String ที่มีคำอธิบายของ Glasswall ID ทั้งหมด
จะมีการโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงข้อมูล ID ทั้งหมดได้
สรุป - ฟังก์ชันที่เลิกใช้แล้ว
import com.glasswall.core2javabridge.*;
(Deprecated)
public int GW2GetAllIdInfo(int session) throws GlasswallException
public byte[] GetAllIDBuffer(int session) throws GlasswallException
คำอธิบาย - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetAllIdInfo จะส่งออกคำอธิบายของ Glasswall ID ทั้งหมดสำหรับเซสชันที่ระบุโดย session ไปยัง All ID Buffer ภายใน ดึงข้อมูลนี้ได้โดยใช้ฟังก์ชัน GetAllIDBuffer
ค่าที่ส่งกลับ - ฟังก์ชันที่เลิกใช้แล้ว
ฟังก์ชัน GW2GetAllIdInfo จะส่งคืนค่าแจงนับ GW2_RetStatus ที่แปลงเป็น int ค่าเป็นลบหมายความว่าเกิดข้อผิดพลาด 0 หมายถึงสำเร็จ โปรดดูรายละเอียดใน API Overview/Return types
GetAllIDBuffer จะส่งคืนอาร์เรย์ไบต์ที่มีคำอธิบาย Glasswall ID โดยจะเป็น null หากยังไม่ได้เรียก GW2GetAllIdInfo
จะมีการโยนข้อยกเว้น GlasswallException หาก session ไม่ถูกต้อง หรือหากไม่สามารถดึงข้อมูล ID ทั้งหมดได้
สรุป
ดึง XML ที่มีช่วง Issue ID ทั้งหมดพร้อมคำอธิบายกลุ่มของแต่ละช่วง
def get_all_id_info(self, output_file: Optional[str] = None, raise_unsupported: bool = True) -> str:
""" Retrieves the XML containing all the Issue ID ranges with their group descriptions
Args:
output_file (Optional[str], optional): The output file path where the analysis file will be written.
raise_unsupported (bool, optional): Default True. Raise exceptions when Glasswall encounters an error. Fail silently if False.
Returns:
all_id_info (str): A string XML analysis report containing all id info.
"""
ส่งกลับ
รายงานการวิเคราะห์ XML แบบสตริงที่มีข้อมูล id ทั้งหมด
สรุป
/**
* This function places a pointer in a specified location to XML data populated with
* Glasswall Issue ID descriptions and value ranges, for a specified session.
*
* @param {number} session The ID of the session.
* @param {number} bufferLength The length of the buffer.
* @param {string} outputBuffer The location of the output buffer.
*/
GW2GetAllIdInfo(
session,
bufferLength,
outputBuffer)
ส่งกลับ
ส่งกลับค่า 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 output_file_buffer = ref.alloc(ref.refType(ref.types.CString));
let output_buffer_size = ref.alloc(ref.types.size_t, 0);
let return_status = gw.GW2GetAllIdInfo(session_id, output_buffer_size, output_file_buffer);
let xml_string = buffer_to_string(output_file_buffer, output_buffer_size);
...