nfd2/
ffi.rs

1/*
2Copyright (c) 2016 Saurav Sachidanand
3
4Permission is hereby granted, free of charge, to any person obtaining a copy
5of this software and associated documentation files (the "Software"), to deal
6in the Software without restriction, including without limitation the rights
7to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8copies of the Software, and to permit persons to whom the Software is
9furnished to do so, subject to the following conditions:
10
11The above copyright notice and this permission notice shall be included in
12all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20THE SOFTWARE.
21*/
22
23/* automatically generated by rust-bindgen */
24
25#![allow(
26    dead_code,
27    non_camel_case_types,
28    non_upper_case_globals,
29    non_snake_case
30)]
31
32use std::os::raw;
33pub type ptrdiff_t = isize;
34pub type size_t = usize;
35pub type nfdchar_t = raw::c_char;
36
37#[repr(C)]
38#[derive(Copy, Clone, Debug)]
39pub struct nfdpathset_t {
40    pub buf: *mut nfdchar_t,
41    pub indices: *mut size_t,
42    pub count: size_t,
43}
44
45impl Default for nfdpathset_t {
46    fn default() -> Self {
47        unsafe { std::mem::zeroed() }
48    }
49}
50
51#[derive(Copy, Clone)]
52#[repr(u32)]
53#[derive(Debug)]
54pub enum nfdresult_t {
55    Error = 0,
56    Okay = 1,
57    Cancel = 2,
58}
59
60extern "C" {
61    pub fn NFD_OpenDialog(
62        filterList: *const nfdchar_t,
63        defaultPath: *const nfdchar_t,
64        outPath: *mut *mut nfdchar_t,
65    ) -> nfdresult_t;
66    pub fn NFD_OpenDialogMultiple(
67        filterList: *const nfdchar_t,
68        defaultPath: *const nfdchar_t,
69        outPaths: *mut nfdpathset_t,
70    ) -> nfdresult_t;
71    pub fn NFD_SaveDialog(
72        filterList: *const nfdchar_t,
73        defaultPath: *const nfdchar_t,
74        outPath: *mut *mut nfdchar_t,
75    ) -> nfdresult_t;
76    pub fn NFD_PickFolder(
77        defaultPath: *const nfdchar_t,
78        outPath: *mut *mut nfdchar_t,
79    ) -> nfdresult_t;
80    pub fn NFD_GetError() -> *const raw::c_char;
81    pub fn NFD_PathSet_GetCount(pathSet: *const nfdpathset_t) -> size_t;
82    pub fn NFD_PathSet_GetPath(pathSet: *const nfdpathset_t, index: size_t) -> *mut nfdchar_t;
83    pub fn NFD_PathSet_Free(pathSet: *mut nfdpathset_t);
84    pub fn NFD_Free(ptr: *mut std::os::raw::c_void);
85}