GW2RegisterPoliciesFile
GW2RegisterPoliciesFile mendaftarkan fail XML policy pengurusan kandungan kepada sesi.
Jika kedua-dua GW2RegisterPoliciesFile atau GW2RegisterPoliciesMemory tidak didaftarkan dengan sesi, policy lalai akan digunakan pada sesi tersebut. Policy lalai menetapkan semua suis pengurusan kandungan kepada Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
Sinopsis
Fungsi GW2RegisterPoliciesFile meminta agar session menggunakan policy yang ditentukan dalam fail yang namanya ialah rentetan yang ditunjukkan oleh filename. Format policy adalah dalam format yang ditentukan oleh format. Policy tersebut akan digunakan pada semua pemprosesan yang dilakukan oleh Glasswall untuk sesi itu.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesFile(Session session, const char *filename, Policy_format format);
Pulangan
Mengembalikan nilai enum integer GW2_RetStatus. Nombor negatif menunjukkan kegagalan.
Contoh
#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 */
Sinopsis
Mendaftar dengan sesi yang dirujuk oleh session, fail yang ditunjukkan oleh policiesFilePath, dengan format yang ditentukan oleh 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
Pulangan
Mengembalikan nilai enum integer GW2_RetStatus. Nombor negatif menunjukkan kegagalan.
Sinopsis
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
Penerangan
Rujuk API Overview/Return types untuk enumerator yang sah bagi format.
Parameter fungsi GW2RegisterPoliciesFile telah dikemas kini untuk menggunakan String menggantikan byte[]. Fungsi asal telah ditandakan sebagai deprecated.
Pulangan
Fungsi GW2RegisterPoliciesFile mengembalikan enumerasi GW2_RetStatus yang ditukarkan kepada int. Nilainya akan menjadi negatif jika ralat berlaku. 0 menunjukkan kejayaan. Rujuk API Overview/Return types untuk butiran lanjut.
Pengecualian NullPointerException akan dilemparkan jika policiesFilePath ialah null atau kosong.
Pengecualian GlasswallException akan dilemparkan jika session tidak sah, jika policiesFilePath tidak dapat diperoleh, atau jika policiesFilePath tidak dapat ditukarkan kepada UTF-8.
Sinopsis
Menetapkan konfigurasi policy pengurusan kandungan. Jika input_file ialah None maka tetapan lalai (sanitise) digunakan.
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'.
"""
Pulangan
Objek dengan atribut yang berbeza bergantung pada jenis input_file.
-
Jika input_file ialah laluan fail str:
- gw_return_object (glasswall.GwReturnObj): Instance GwReturnObj dengan atribut 'session', 'input_file', 'policy_format', 'status'.
-
Jika input_file ialah fail dalam memori:
- gw_return_object (glasswall.GwReturnObj): Instance GwReturnObj dengan atribut 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
Atribut status ialah nilai enum integer GW2_RetStatus. Nombor negatif menunjukkan kegagalan.
Sinopsis
Fungsi ini meminta agar sesi yang ditentukan menggunakan policy dalam fail yang ditentukan.
/**
* @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)
Pulangan
Mengembalikan nilai enum integer GW2_RetStatus. Nombor negatif menunjukkan kegagalan.