// Package glib was automatically generated by github.com/bnema/puregotk DO NOT EDIT package glib import ( "structs" "unsafe" "github.com/ebitengine/purego" "github.com/bnema/puregotk/pkg/core" "github.com/bnema/puregotk/v4/gobject/types" ) // GLib provides a generic API for computing checksums (or ‘digests’) // for a sequence of arbitrary bytes, using various hashing algorithms // like MD5, SHA-1 and SHA-256. Checksums are commonly used in various // environments and specifications. // // To create a new `GChecksum`, use [ctor@GLib.Checksum.new]. To free // a `GChecksum`, use [method@GLib.Checksum.free]. // // GLib supports incremental checksums using the `GChecksum` data // structure, by calling [method@GLib.Checksum.update] as long as there’s data // available and then using [method@GLib.Checksum.get_string] or // [method@GLib.Checksum.get_digest] to compute the checksum and return it // either as a string in hexadecimal form, or as a raw sequence of bytes. To // compute the checksum for binary blobs and nul-terminated strings in // one go, use the convenience functions [func@GLib.compute_checksum_for_data] // and [func@GLib.compute_checksum_for_string], respectively. type Checksum struct { _ structs.HostLayout } var xChecksumGLibType func() types.GType func ChecksumGLibType() types.GType { return xChecksumGLibType() } func (x *Checksum) GoPointer() uintptr { return uintptr(unsafe.Pointer(x)) } var xNewChecksum func(ChecksumType) *Checksum // Creates a new #GChecksum, using the checksum algorithm @checksum_type. // If the @checksum_type is not known, %NULL is returned. // A #GChecksum can be used to compute the checksum, or digest, of an // arbitrary binary blob, using different hashing algorithms. // // A #GChecksum works by feeding a binary blob through g_checksum_update() // until there is data to be checked; the digest can then be extracted // using g_checksum_get_string(), which will return the checksum as a // hexadecimal string; or g_checksum_get_digest(), which will return a // vector of raw bytes. Once either g_checksum_get_string() or // g_checksum_get_digest() have been called on a #GChecksum, the checksum // will be closed and it won't be possible to call g_checksum_update() // on it anymore. func NewChecksum(ChecksumTypeVar ChecksumType) *Checksum { cret := xNewChecksum(ChecksumTypeVar) return cret } var xChecksumCopy func(uintptr) *Checksum // Copies a #GChecksum. If @checksum has been closed, by calling // g_checksum_get_string() or g_checksum_get_digest(), the copied // checksum will be closed as well. func (x *Checksum) Copy() *Checksum { cret := xChecksumCopy(x.GoPointer()) return cret } var xChecksumFree func(uintptr) // Frees the memory allocated for @checksum. func (x *Checksum) Free() { xChecksumFree(x.GoPointer()) } var xChecksumGetDigest func(uintptr, []byte, uint) // Gets the digest from @checksum as a raw binary vector and places it // into @buffer. The size of the digest depends on the type of checksum. // // Once this function has been called, the #GChecksum is closed and can // no longer be updated with g_checksum_update(). func (x *Checksum) GetDigest(BufferVar []byte, DigestLenVar uint) { xChecksumGetDigest(x.GoPointer(), BufferVar, DigestLenVar) } var xChecksumGetString func(uintptr) string // Gets the digest as a hexadecimal string. // // Once this function has been called the #GChecksum can no longer be // updated with g_checksum_update(). // // The hexadecimal characters will be lower case. func (x *Checksum) GetString() string { cret := xChecksumGetString(x.GoPointer()) return cret } var xChecksumReset func(uintptr) // Resets the state of the @checksum back to its initial state. func (x *Checksum) Reset() { xChecksumReset(x.GoPointer()) } var xChecksumUpdate func(uintptr, []byte, int) // Feeds @data into an existing #GChecksum. The checksum must still be // open, that is g_checksum_get_string() or g_checksum_get_digest() must // not have been called on @checksum. func (x *Checksum) Update(DataVar []byte, LengthVar int) { xChecksumUpdate(x.GoPointer(), DataVar, LengthVar) } // The hashing algorithm to be used by #GChecksum when performing the // digest of some data. // // Note that the #GChecksumType enumeration may be extended at a later // date to include new hashing algorithm types. type ChecksumType int const ( // Use the MD5 hashing algorithm GChecksumMd5Value ChecksumType = 0 // Use the SHA-1 hashing algorithm GChecksumSha1Value ChecksumType = 1 // Use the SHA-256 hashing algorithm GChecksumSha256Value ChecksumType = 2 // Use the SHA-512 hashing algorithm (Since: 2.36) GChecksumSha512Value ChecksumType = 3 // Use the SHA-384 hashing algorithm (Since: 2.51) GChecksumSha384Value ChecksumType = 4 ) var xChecksumTypeGetLength func(ChecksumType) int // Gets the length in bytes of digests of type @checksum_type func ChecksumTypeGetLength(ChecksumTypeVar ChecksumType) int { cret := xChecksumTypeGetLength(ChecksumTypeVar) return cret } var xComputeChecksumForBytes func(ChecksumType, *Bytes) string // Computes the checksum for a binary @data. This is a // convenience wrapper for g_checksum_new(), g_checksum_get_string() // and g_checksum_free(). // // The hexadecimal string returned will be in lower case. func ComputeChecksumForBytes(ChecksumTypeVar ChecksumType, DataVar *Bytes) string { cret := xComputeChecksumForBytes(ChecksumTypeVar, DataVar) return cret } var xComputeChecksumForData func(ChecksumType, []byte, uint) string // Computes the checksum for a binary @data of @length. This is a // convenience wrapper for g_checksum_new(), g_checksum_get_string() // and g_checksum_free(). // // The hexadecimal string returned will be in lower case. func ComputeChecksumForData(ChecksumTypeVar ChecksumType, DataVar []byte, LengthVar uint) string { cret := xComputeChecksumForData(ChecksumTypeVar, DataVar, LengthVar) return cret } var xComputeChecksumForString func(ChecksumType, string, int) string // Computes the checksum of a string. // // The hexadecimal string returned will be in lower case. func ComputeChecksumForString(ChecksumTypeVar ChecksumType, StrVar string, LengthVar int) string { cret := xComputeChecksumForString(ChecksumTypeVar, StrVar, LengthVar) return cret } func init() { core.SetPackageName("GLIB", "glib-2.0") core.SetSharedLibraries("GLIB", []string{"libgobject-2.0.so.0", "libglib-2.0.so.0"}) var libs []uintptr for _, libPath := range core.GetPaths("GLIB") { lib, err := purego.Dlopen(libPath, purego.RTLD_NOW|purego.RTLD_GLOBAL) if err != nil { panic(err) } libs = append(libs, lib) } core.PuregoSafeRegister(&xChecksumTypeGetLength, libs, "g_checksum_type_get_length") core.PuregoSafeRegister(&xComputeChecksumForBytes, libs, "g_compute_checksum_for_bytes") core.PuregoSafeRegister(&xComputeChecksumForData, libs, "g_compute_checksum_for_data") core.PuregoSafeRegister(&xComputeChecksumForString, libs, "g_compute_checksum_for_string") core.PuregoSafeRegister(&xChecksumGLibType, libs, "g_checksum_get_type") core.PuregoSafeRegister(&xNewChecksum, libs, "g_checksum_new") core.PuregoSafeRegister(&xChecksumCopy, libs, "g_checksum_copy") core.PuregoSafeRegister(&xChecksumFree, libs, "g_checksum_free") core.PuregoSafeRegister(&xChecksumGetDigest, libs, "g_checksum_get_digest") core.PuregoSafeRegister(&xChecksumGetString, libs, "g_checksum_get_string") core.PuregoSafeRegister(&xChecksumReset, libs, "g_checksum_reset") core.PuregoSafeRegister(&xChecksumUpdate, libs, "g_checksum_update") }