GW2RegisterPoliciesMemory
GW2RegisterPoliciesMemory mendaftarkan file XML policy manajemen konten yang disimpan dalam memori ke sebuah sesi.
Jika baik GW2RegisterPoliciesFile maupun GW2RegisterPoliciesMemory tidak didaftarkan dengan sebuah sesi, policy default akan diterapkan ke sesi tersebut. Policy default menetapkan semua sakelar manajemen konten ke Sanitise.
- C++
- C#
- Java
- Python
- JavaScript
Sinopsis
Untuk sesi session, fungsi GW2RegisterPoliciesMemory mendaftarkan policy yang akan digunakan oleh Glasswall saat memproses file. policies adalah pointer ke data policy, policiesLength menentukan ukuran data policy dalam byte, dan policiesFormat menentukan format data policy.
#include "glasswall.core2.api.h"
int GW2RegisterPoliciesMemory(Session session,
const char *policies,
size_t policiesLength,
Policy_format format);
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.
Contoh
#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 */
Sinopsis
Mendaftarkan policy yang akan digunakan oleh Glasswall saat memproses file
/// <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)
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.
Sinopsis
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
Catatan
Lihat API Overview/Return types untuk enumerator yang valid bagi format.
length dari policiesBuffer dapat ditentukan secara opsional.
Hasil pengembalian
Fungsi GW2RegisterPoliciesMemory mengembalikan enumerasi GW2_RetStatus yang dikonversi menjadi int. Nilainya akan negatif jika terjadi kesalahan. 0 menunjukkan keberhasilan. Lihat API Overview/Return types untuk detailnya.
Exception GlasswallException akan dilempar jika session tidak valid.
Exception NullPointerException akan dilempar jika policiesBuffer bernilai null atau kosong.
Sinopsis
Menetapkan konfigurasi policy manajemen konten. Jika input_file adalah None maka pengaturan default (sanitise) diterapkan.
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'.
"""
Hasil pengembalian
Sebuah objek dengan atribut yang berbeda tergantung pada tipe input_file.
-
Jika input_file adalah path file str:
- gw_return_object (glasswall.GwReturnObj): Instance GwReturnObj dengan atribut 'session', 'input_file', 'policy_format', 'status'.
-
Jika input_file adalah file di memori:
- gw_return_object (glasswall.GwReturnObj): Instance GwReturnObj dengan atribut 'session', 'buffer', 'buffer_length', 'policy_format', 'status'.
Atribut status adalah nilai enum bilangan bulat GW2_RetStatus. Angka negatif menunjukkan kegagalan.
Sinopsis
Fungsi ini meminta agar sesi yang ditentukan menggunakan policy yang disimpan dalam buffer memori yang ditentukan.
/**
* @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)
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.