GW2RegisterPoliciesMemory
GW2RegisterPoliciesMemory đăng ký tệp XML policy quản lý nội dung được giữ trong bộ nhớ vào một phiên.
Nếu cả GW2RegisterPoliciesFile và GW2RegisterPoliciesMemory đều không được đăng ký với một phiên, các policy mặc định sẽ được áp dụng cho phiên đó. policy mặc định đặt tất cả các công tắc quản lý nội dung thành Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
Tóm tắt
Đối với phiên session, hàm GW2RegisterPoliciesMemory đăng ký các policy sẽ được Glasswall sử dụng khi xử lý tệp. policies là một con trỏ tới dữ liệu policy, policiesLength chỉ định kích thước tính bằng byte của dữ liệu policy, và policiesFormat chỉ định định dạng của dữ liệu policy.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesMemory(Session session,
const char *policies,
size_t policiesLength,
Policy_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 session = GW2OpenSession();
char *policies = NULL;
size_t size = 0;
if (!session)
/* deal with error */
else
{
/* ... load 'policies' with a pointer to the policies content ... */
if (GW2RegisterPoliciesMemory(session, policies, size, PF_XML) < 0)
/* deal with error */
else
/* continue processing */
}
. . .
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Tóm tắt
Đăng ký các policy sẽ được Glasswall sử dụng khi xử lý tệp
/// <param name="session">Session ID number</param>
/// <param name="policies">The policy file</param>
/// <param name="policiesFormat">Format of the policies data</param>
public int RegisterPoliciesMemory(
int session,
byte[] policies,
int policiesFormat)
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 GW2RegisterPoliciesMemory(int session, byte[] policiesBuffer, int format) throws GlasswallException, NullPointerException
public int GW2RegisterPoliciesMemory(int session, byte[] policiesBuffer, int length, int format) throws GlasswallException, NullPointerException
Lưu ý
Tham khảo API Overview/Return types để biết các giá trị liệt kê hợp lệ cho format.
length của policiesBuffer có thể được chỉ định tùy chọn.
Giá trị trả về
Hàm GW2RegisterPoliciesMemory 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ệ.
Một ngoại lệ NullPointerException sẽ được ném ra nếu policiesBuffer là null hoặc rỗng.
Tóm tắt
Thiết lập cấu hình policy quản lý nội dung. Nếu input_file là None thì các thiết lập mặc định (sanitise) sẽ được áp dụng.
def set_content_management_policy(self, session: int, input_file: Union[None, str, bytes, bytearray, io.BytesIO, "glasswall.content_management.policies.policy.Policy"] = None, policy_format=0):
""" Sets the content management policy configuration. If input_file is None then default settings (sanitise) are applied.
Args:
session (int): The session integer.
input_file (Union[None, str, bytes, bytearray, io.BytesIO, glasswall.content_management.policies.policy.Policy], optional): Default None (sanitise). The content management policy to apply.
policy_format (int): The format of the content management policy. 0=XML.
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', 'policy_format', 'status'.
- If input_file is a file in memory:
- gw_return_object (glasswall.GwReturnObj): A GwReturnObj instance with the attributes 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
"""
Giá trị trả về
Một đối tượng có các thuộc tính khác nhau tùy thuộc vào kiểu của input_file.
-
Nếu input_file là đường dẫn tệp str:
- gw_return_object (glasswall.GwReturnObj): Một thực thể GwReturnObj với các thuộc tính 'session', 'input_file', 'policy_format', 'status'.
-
Nếu input_file là tệp trong bộ nhớ:
- gw_return_object (glasswall.GwReturnObj): Một thực thể GwReturnObj với các thuộc tính 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
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 yêu cầu phiên được chỉ định sử dụng các policy được lưu trữ trong một bộ đệm bộ nhớ được chỉ định.
/**
* @param {number} session The ID of the session.
* @param {string} policies A pointer to the policy data buffer.
* @param {number} policiesLength The length of the data in the policy buffer.
* @param {number} format The format of the policy.
*/
GW2RegisterPoliciesMemory(
session,
policies,
policyLength,
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.