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
use crate::{host::*, id::*, plugin::*};

use std::os::raw::c_char;

pub const CLAP_EXT_FILE_REFERENCE: *const c_char =
    b"clap.file-reference.draft/0\0".as_ptr() as *const c_char;

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

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