GW2RegisterPoliciesFile
GW2RegisterPoliciesFile đăng ký tệp XML policy quản lý nội dung 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
Hàm GW2RegisterPoliciesFile yêu cầu session sử dụng các policy được chỉ định trong tệp có tên là chuỗi được filename trỏ tới. Định dạng của các policy theo định dạng được chỉ định bởi format. Các policy sẽ được áp dụng cho mọi quá trình xử lý do Glasswall thực hiện cho phiên đó.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesFile(Session session, const char *filename, 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"
HANDLE session = GW2OpenSession();
if (!session)
/* deal with error */
else
if (GW2RegisterPoliciesFile(session, "Office_Binary_Policies.xml", PF_XML) < 0)
/* deal with error */
else
/* the file has been successfully registered */
...
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Tóm tắt
Đăng ký với phiên được tham chiếu bởi session, tệp được policiesFilePath trỏ tới, với định dạng được chỉ định bởi policiesFormat
/// <param name="session">ID number for the session</param>
/// <param name="policiesFilePath">The file path to the file to be processed</param>
/// <param name="policiesFormat">Format of the policy file</param>
public int RegisterPoliciesFile(
int session,
string policiesFilePath,
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 GW2RegisterPoliciesFile(int session, String policiesFilePath, int format) throws GlasswallException, NullPointerException
(Deprecated)
public int GW2RegisterPoliciesFile(int session, byte[] policiesFilePath, int format) throws GlasswallException, NullPointerException
Mô tả
Tham khảo API Overview/Return types để biết các giá trị liệt kê hợp lệ cho format.
Các tham số của hàm GW2RegisterPoliciesFile đã được cập nhật để sử dụng String thay cho byte[]. Hàm gốc đã bị ngừng dùng.
Giá trị trả về
Hàm GW2RegisterPoliciesFile trả về một kiểu 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.
Ngoại lệ NullPointerException sẽ được ném ra nếu policiesFilePath là null hoặc rỗng.
Ngoại lệ GlasswallException sẽ được ném ra nếu session không hợp lệ, nếu không thể truy xuất policiesFilePath, hoặc nếu không thể chuyển đổi policiesFilePath sang UTF-8.
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 trong tệp được chỉ định.
/**
* @param {number} session The ID of the session.
* @param {string} filename The filename from which to load policy settings.
* @param {number} format - The format of the policy to be registered.
*/
GW2RegisterPoliciesFile(
session,
filename,
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.