1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
use crate::{host::*, id::*, plugin::*};

use std::ffi::CStr;
use std::os::raw::c_char;

pub const CLAP_EXT_FILE_REFERENCE: &CStr =
    unsafe { CStr::from_bytes_with_nul_unchecked(b"clap.file-reference.draft/0\0") };

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_file_reference {
    pub resource_id: clap_id,
    pub belongs_to_plugin_collection: bool,
    pub path_capacity: usize,
    pub path_size: usize,
    pub path: *mut c_char,
}

unsafe impl Send for clap_file_reference {}
unsafe impl Sync for clap_file_reference {}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_plugin_file_reference {
    pub count: Option<unsafe extern "C" fn(plugin: *const clap_plugin) -> u32>,
    pub get: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            index: u32,
            file_reference: *mut clap_file_reference,
        ) -> bool,
    >,
    pub get_blake3_digest: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            resource_id: clap_id,
            digest: *mut u8,
        ) -> bool,
    >,
    pub get_file_size: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            resource_id: clap_id,
            size: *mut u64,
        ) -> bool,
    >,
    pub update_path: Option<
        unsafe extern "C" fn(
            plugin: *const clap_plugin,
            resource_id: clap_id,
            path: *const c_char,
        ) -> bool,
    >,
    pub save_resources: Option<unsafe extern "C" fn(plugin: *const clap_plugin) -> bool>,
}

#[repr(C)]
#[derive(Debug, Copy, Clone)]
pub struct clap_host_file_reference {
    pub changed: Option<unsafe extern "C" fn(host: *const clap_host)>,
    pub set_dirty: Option<unsafe extern "C" fn(host: *const clap_host, resource_id: clap_id)>,
}