38 lines
1.3 KiB
C
38 lines
1.3 KiB
C
#pragma once
|
|
|
|
// C API of the att_adblock Rust crate (adblock/src/lib.rs), a thin wrapper
|
|
// over Brave's adblock-rust. Keep the two in sync by hand.
|
|
|
|
#include <stdbool.h>
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
typedef struct AttAdblockEngine AttAdblockEngine;
|
|
|
|
// Compiles filter list text; several lists may be concatenated. Null on failure.
|
|
AttAdblockEngine *att_adblock_engine_from_rules(const uint8_t *rules, size_t len);
|
|
|
|
// Loads data from att_adblock_engine_serialize. Null if it is corrupt or from an
|
|
// incompatible adblock-rust version.
|
|
AttAdblockEngine *att_adblock_engine_deserialize(const uint8_t *data, size_t len);
|
|
|
|
// The returned buffer must be released with att_adblock_buffer_free.
|
|
uint8_t *att_adblock_engine_serialize(const AttAdblockEngine *engine, size_t *out_len);
|
|
void att_adblock_buffer_free(uint8_t *data, size_t len);
|
|
|
|
void att_adblock_engine_free(AttAdblockEngine *engine);
|
|
|
|
// All strings are NUL-terminated UTF-8. request_type uses webRequest names
|
|
// ("script", "image", "xhr", "sub_frame", ...). Thread-safe.
|
|
bool att_adblock_should_block(const AttAdblockEngine *engine, const char *url,
|
|
const char *source_url, const char *request_type,
|
|
const char *method);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|