GW2RegisterLicenceMemory
GW2RegisterLicenceMemory mendaftarkan file licence yang disimpan dalam memori ke sebuah sesi.
Jika GW2RegisterLicenceFile maupun GW2RegisterLicenceMemory tidak didaftarkan ke sebuah sesi, Editor akan mencoba mencari lisensi di lokasi default. Ini adalah file bernama gwkey.lic yang berada di folder yang sama dengan library Editor. Jika file tersebut tidak dapat ditemukan, maka library akan dianggap tidak berlisensi dan beberapa proses mungkin gagal karena masalah kedaluwarsa lisensi.
- C++
- C#
- Java
- Python
- JavaScript
Sinopsis
Untuk sesi session, fungsi GW2RegisterLicenceMemory mendaftarkan licence yang akan digunakan oleh Glasswall saat memproses file. licenceContents adalah pointer ke data licence, licenceLength menentukan ukuran data licence dalam byte.
#include "glasswall.core2.api.h"
int GW2RegisterLicenceMemory(Session session,
const char *licenceContents,
size_t licenceLength);
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.
Contoh
#include "glasswall.core2.api.h"
Session session = GW2OpenSession();
char *licence = NULL;
size_t size = 0;
if (!session)
/* deal with error */
else
{
/* ... load 'licence' with a pointer to the licence content ... */
if (GW2RegisterLicenceMemory(session, licence, size) < 0)
/* deal with error */
else
/* continue processing */
}
. . .
/* later */
if (GW2CloseSession(session) < 0)
/* error closing session */
Sinopsis
Untuk sesi session, metode RegisterLicenceMemory mendaftarkan licence yang akan digunakan oleh Glasswall saat memproses file.
/// <summary>
/// Provide a licence to use for the session.
/// </summary>
/// <param name="session">Current open Glasswall session</param>
/// <param name="licence">Byte content of the licence</param>
public int RegisterLicenceMemory(int session, byte[] licence)
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.
Sinopsis
import com.glasswall.core2javabridge.*;
public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer) throws GlasswallException, NullPointerException
public int GW2RegisterLicenceMemory(int session, byte[] licenceBuffer, int licenceLength) throws GlasswallException, NullPointerException
Catatan
length dari licenceBuffer dapat ditentukan secara opsional.
Hasil pengembalian
Fungsi GW2RegisterLicenceMemory mengembalikan enumerasi GW2_RetStatus yang dikonversi menjadi int. Nilainya akan negatif jika terjadi error. 0 menunjukkan keberhasilan. Lihat API Overview/Return types untuk detailnya.
Pengecualian GlasswallException akan dilempar jika session tidak valid.
Exception NullPointerException akan dilempar jika buffer licenceBuffer bernilai null atau kosong.
Pendaftaran lisensi untuk setiap sesi ditangani secara otomatis dalam wrapper Python, dan pengguna tidak perlu memanggil GW2RegisterLicenceFile atau GW2RegisterLicenceMemory secara manual.
Secara default, class Editor mengharapkan file lisensi yang valid berada di direktori yang sama dengan library_path. Anda juga dapat menentukan jalur berbeda ke file lisensi gwkey.lic menggunakan argumen licence.
import glasswall
# Load the Glasswall Editor library with a specified licence file
editor = glasswall.Editor(r"C:\gwpw\libraries\10.0", licence=r"C:\gwpw\licence\gwkey.lic")
Sebagai alternatif, Anda dapat meneruskan data lisensi di memori sebagai objek bytes, bytearray, atau io.BytesIO.
import glasswall
# Alternatively, load the licence from in-memory bytes or bytearray
with open(r"C:\gwpw\licence\gwkey.lic", "rb") as f:
licence_data = f.read()
editor = glasswall.Editor(
r"C:\gwpw\libraries\10.0",
licence=licence_data # In-memory licence data
)
Sinopsis
Untuk sesi session, fungsi GW2RegisterLicenceMemory mendaftarkan licence yang akan digunakan oleh Glasswall saat memproses file. licenceContents adalah pointer ke data licence, licenceLength menentukan ukuran data licence dalam byte.
/**
* Provides the contents of the licence file that will be used for this session.
* @param {number} session The ID of the session.
* @param {string} licenceContents A pointer to the licence data buffer.
* @param {number} licenceLength Length of the data in the licence buffer.
* @returns {number} Status of the operation; 0 for success, non-zero for failure.
*/
GW2RegisterLicenceMemory(session, licenceContents, licenceLength)
Hasil pengembalian
Mengembalikan nilai enum GW2_RetStatus berupa integer. Angka negatif menunjukkan kegagalan.