1#![allow(non_camel_case_types)]
2#![allow(non_snake_case)]
3#![allow(non_upper_case_globals)]
4#![allow(unnecessary_transmutes)]
5
6pub mod errors;
7
8pub use crate::errors::*;
9
10use std::os::raw::c_char;
11
12#[allow(clippy::all)]
13mod bindings {
14 include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
15}
16pub use bindings::*;
17
18pub mod scan_flags {
19 pub use super::{
20 SCAN_FLAGS_FAST_MODE, SCAN_FLAGS_NO_TRYCATCH, SCAN_FLAGS_PROCESS_MEMORY,
21 SCAN_FLAGS_REPORT_RULES_MATCHING, SCAN_FLAGS_REPORT_RULES_NOT_MATCHING,
22 };
23}
24
25#[derive(Clone, Copy, Debug, Eq, PartialEq)]
26pub enum MetaType {
27 Integer,
28 String,
29 Boolean,
30}
31
32impl MetaType {
33 #[deny(unused_variables)]
34 pub fn from_code(code: i32) -> Result<Self, i32> {
35 use self::MetaType::*;
36 match code as u32 {
37 META_TYPE_INTEGER => Ok(Integer),
38 META_TYPE_STRING => Ok(String),
39 META_TYPE_BOOLEAN => Ok(Boolean),
40 _ => Err(code),
41 }
42 }
43}
44
45impl YR_MATCHES {
46 #[deprecated = "Useless now"]
47 pub fn get_head(&self) -> *const YR_MATCH {
48 self.head
49 }
50
51 #[deprecated = "Useless now"]
52 pub fn get_tail(&self) -> *const YR_MATCH {
53 self.tail
54 }
55}
56
57impl YR_META {
59 pub fn get_identifier(&self) -> *const c_char {
60 unsafe { self.__bindgen_anon_1.identifier }
61 }
62
63 pub fn get_string(&self) -> *const c_char {
64 unsafe { self.__bindgen_anon_2.string }
65 }
66}
67
68impl YR_NAMESPACE {
69 pub fn get_name(&self) -> *const c_char {
70 unsafe { self.__bindgen_anon_1.name }
71 }
72}
73
74impl YR_RULES {
75 pub fn get_rules_table(&self) -> *const YR_RULE {
76 unsafe { self.__bindgen_anon_1.rules_table }
77 }
78}
79
80impl YR_RULE {
81 pub fn get_identifier(&self) -> *const c_char {
82 unsafe { self.__bindgen_anon_1.identifier }
83 }
84
85 pub fn get_tags(&self) -> *const c_char {
86 unsafe { self.__bindgen_anon_2.tags }
87 }
88
89 pub fn get_metas(&self) -> *const YR_META {
90 unsafe { self.__bindgen_anon_3.metas }
91 }
92
93 pub fn get_strings(&self) -> *const YR_STRING {
94 unsafe { self.__bindgen_anon_4.strings }
95 }
96
97 pub fn get_ns(&self) -> *const YR_NAMESPACE {
98 unsafe { self.__bindgen_anon_5.ns }
99 }
100
101 pub fn enable(&mut self) {
102 unsafe {
103 yr_rule_enable(self);
104 }
105 }
106
107 pub fn disable(&mut self) {
108 unsafe {
109 yr_rule_disable(self);
110 }
111 }
112}
113
114impl YR_STRING {
115 pub fn get_identifier(&self) -> *const c_char {
116 unsafe { self.__bindgen_anon_3.identifier }
117 }
118
119 pub fn get_string(&self) -> *const c_char {
120 unsafe { self.__bindgen_anon_1.string as _ }
121 }
122}