GW2RegisterAnalysisMemory
GW2RegisterAnalysisMemory đăng ký vị trí bộ nhớ để lưu báo cáo phân tích vào một phiên. Việc sử dụng hàm này sẽ kích hoạt Quy trình Phân tích cho Session.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
Hàm GW2RegisterAnalysisMemory lưu vào đối tượng được trỏ tới bởi analysisFileBuffer một con trỏ tới báo cáo phân tích được tạo ra từ lần chạy thành công của hàm API runSession sử dụng phiên session. Kích thước của báo cáo phân tích, tính bằng byte, được đặt vào đối tượng được trỏ tới bởi analysisLength. Định dạng của báo cáo phân tích sẽ theo định dạng được yêu cầu bởi format. Việc sử dụng hàm này sẽ kích hoạt Chế độ Quy trình Phân tích cho phiên.
#include "glasswall.core2.api.h"
int GW2RegisterAnalysisMemory(Session session,
char **analysisFileBuffer,
size_t analysisLength,
Analysis_format format);
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Ví dụ
#include "glasswall.core2.api.h"
Session_Handle session;
char *analysisReport = NULL;
size_t analysisReportSize = 0;
session = GW2OpenSession();
if (!session)
/* deal with error */
else
{
if (GW2RegisterAnalysisMemory(session, &analysisReport, &analysisReportSize, PF_XML) < 0)
/* deal with error */
else
/* analysisReport points to the analysis report data */
}
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Tóm tắt
public int RegisterAnalysisMemory(
int session,
out IntPtr analysisBufferPtr,
ref UIntPtr analysisBufferLengthPtr,
int Format)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.
Tóm tắt
import com.glasswall.core2javabridge.*;
public int GW2RegisterAnalysisMemory(int session, int format) throws GlasswallException
Mô tả
Hàm GW2RegisterAnalysisMemory đăng ký một bộ đệm bộ nhớ làm đầu ra cho báo cáo phân tích, cho phiên được chỉ định bởi session. Gọi GetAnalysisBuffer hoặc GetAnalysisReport sau khi đã gọi GW2RunSession để truy xuất báo cáo phân tích.
Tham khảo API Overview/Return types để biết các giá trị liệt kê hợp lệ cho format.
Giá trị trả về
Hàm GW2RegisterAnalysisMemory trả về một giá trị liệt kê GW2_RetStatus được chuyển đổi thành int. Giá trị sẽ là số âm nếu xảy ra lỗi. 0 cho biết thành công. Tham khảo API Overview/Return types để biết chi tiết.
Một ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ.
Tóm tắt - Truy xuất dữ liệu
import com.glasswall.core2javabridge.*;
public byte[] GetAnalysisBuffer(int session) throws GlasswallException
public String GetAnalysisReport(int session) throws GlasswallException
Mô tả
Hàm GetAnalysisBuffer truy xuất nội dung của bộ đệm báo cáo phân tích được liên kết với phiên được chỉ định bởi session.
Giá trị trả về
Hàm GetAnalysisBuffer trả về một Byte[] chứa báo cáo phân tích. Hàm GetAnalysisReport trả về một String chứa báo cáo phân tích. Các giá trị này sẽ là null nếu cả GW2RunSession và GW2RegisterAnalysisMemory chưa được gọi.
Một ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ.
Tóm tắt
Đăng ký một tệp phân tích cho session đã cho. Tệp phân tích sẽ được tạo trong lệnh gọi run_session của session.
def register_analysis(self, session: int, output_file: Optional[str] = None):
""" Registers an analysis file for the given session. The analysis file will be created during the session's run_session call.
Args:
session (int): The session integer.
output_file (Optional[str]): Default None. The file path where the analysis will be written. None returns the analysis as bytes.
Returns:
gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'status', 'session', 'analysis_format'. If output_file is None (memory mode), 'buffer', and 'buffer_length' are included containing the file content and file size. If output_file is not None (file mode) 'output_file' is included.
"""
Giá trị trả về
gw_return_object (glasswall.GwReturnObj): Một thực thể GwReturnObj với các thuộc tính 'status', 'session', 'analysis_format'. Nếu output_file là None (chế độ bộ nhớ), 'buffer' và 'buffer_length' sẽ được bao gồm, chứa nội dung tệp và kích thước tệp. Nếu output_file không phải là None (chế độ tệp) thì 'output_file' sẽ được bao gồm.
Thuộc tính status là một giá trị enum GW2_RetStatus kiểu số nguyên. Các số âm cho biết thất bại.
Tóm tắt
Hàm này lưu trữ một con trỏ tới báo cáo phân tích được tạo ra bởi lần chạy thành công của runSession.
/**
*
* @param {number} session The ID of the session.
* @param {string} analysisFileBuffer The pointer to the location of the analysis report.
* @param {number} analysisOutputLength The size of the analysis report.
* @param {number} format The specified format.
*/
GW2RegisterAnalysisMemory(
session,
analysisFileBuffer,
analysisOutputLength,
format)
Giá trị trả về
Trả về một giá trị enum GW2_RetStatus dạng số nguyên. Các số âm cho biết thất bại.