use libc::{c_char, c_int, size_t};
pub mod consts;
pub use consts::*;
pub enum Xmp {}
pub enum XmpFile {}
pub enum XmpString {}
pub enum XmpIterator {}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[repr(i32)]
pub enum XmpError {
Unknown = 0,
TBD = -1,
Unavailable = -2,
BadObject = -3,
BadParam = -4,
BadValue = -5,
AssertFailure = -6,
EnforceFailure = -7,
Unimplemented = -8,
InternalFailure = -9,
Deprecated = -10,
ExternalFailure = -11,
UserAbort = -12,
StdException = -13,
UnknownException = -14,
NoMemory = -15,
BadSchema = -101,
BadXPath = -102,
BadOptions = -103,
BadIndex = -104,
BadIterPosition = -105,
BadParse = -106,
BadSerialize = -107,
BadFileFormat = -108,
NoFileHandler = -109,
TooLargeForJPEG = -110,
BadXML = -201,
BadRDF = -202,
BadXMP = -203,
EmptyIterator = -204,
BadUnicode = -205,
BadTIFF = -206,
BadJPEG = -207,
BadPSD = -208,
BadPSIR = -209,
BadIPTC = -210,
BadMPEG = -211,
}
#[derive(Clone, Copy, Eq, PartialEq, Debug)]
#[repr(i8)]
pub enum TzSign {
West = -1,
UTC = 0,
East = 1,
}
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct XmpDateTime {
pub year: i32,
pub month: i32,
pub day: i32,
pub hour: i32,
pub minute: i32,
pub second: i32,
pub has_date: i8,
pub has_time: i8,
pub has_tz: i8,
pub tz_sign: TzSign,
pub tz_hour: i32,
pub tz_minute: i32,
pub nano_second: i32,
}
impl Default for XmpDateTime {
fn default() -> Self {
unsafe { ::std::mem::zeroed() }
}
}
#[repr(C)]
pub struct XmpPacketInfo {
pub offset: i64,
pub length: i32,
pub pad_size: i32,
pub char_form: u8,
pub writeable: bool,
pub has_wrapper: bool,
pub pad: u8,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[repr(u32)]
pub enum FileType {
PDF = 0x50444620u32, PS = 0x50532020u32, EPS = 0x45505320u32, JPEG = 0x4A504547u32, JPEG2K = 0x4A505820u32, TIFF = 0x54494646u32, GIF = 0x47494620u32, PNG = 0x504E4720u32, WEBP = 0x57454250u32, SWF = 0x53574620u32, FLA = 0x464C4120u32, FLV = 0x464C5620u32, MOV = 0x4D4F5620u32, AVI = 0x41564920u32, CIN = 0x43494E20u32, WAV = 0x57415620u32, MP3 = 0x4D503320u32, SES = 0x53455320u32, CEL = 0x43454C20u32, MPEG = 0x4D504547u32, MPEG2 = 0x4D503220u32, MPEG4 = 0x4D503420u32, MXF = 0x4D584620u32, WMAV = 0x574D4156u32, AIFF = 0x41494646u32, RED = 0x52454420u32, ARRI = 0x41525249u32, HEIF = 0x48454946u32, P2 = 0x50322020u32, XDCAMFam = 0x58444346u32, XDCAMSam = 0x58444353u32, XDCAMEx = 0x58444358u32, AVCHD = 0x41564844u32, SonyHDV = 0x53484456u32, CanonXF = 0x434E5846u32, AVCUltra = 0x41564355u32, HTML = 0x48544D4Cu32, XML = 0x584D4C20u32, TEXT = 0x74657874u32, SVG = 0x53564720u32, Photoshop = 0x50534420u32, Illustrator = 0x41492020u32, InDesign = 0x494E4444u32, AEProject = 0x41455020u32, AEProjTemplate = 0x41455420u32, AEFilterPreset = 0x46465820u32, EncoreProject = 0x4E434F52u32, PremiereProject = 0x5052504Au32, PremiereTitle = 0x5052544Cu32, UCFFile = 0x55434620u32, Unknown = 0x20202020u32, }
#[link(name = "exempi")]
extern "C" {
pub fn xmp_init() -> bool;
pub fn xmp_terminate();
pub fn xmp_get_error() -> c_int;
pub fn xmp_files_new() -> *mut XmpFile;
pub fn xmp_files_open_new(p: *const c_char, options: u32 ) -> *mut XmpFile;
pub fn xmp_files_open(
xf: *mut XmpFile,
p: *const c_char,
options: u32, ) -> bool;
pub fn xmp_files_close(xf: *mut XmpFile, options: u32 ) -> bool;
pub fn xmp_files_get_new_xmp(xf: *mut XmpFile) -> *mut Xmp;
pub fn xmp_files_get_xmp(xf: *mut XmpFile, xmp: *mut Xmp) -> bool;
pub fn xmp_files_get_xmp_xmpstring(
xf: *mut XmpFile,
xmp_packet: *mut XmpString,
packet_info: *mut XmpPacketInfo,
) -> bool;
pub fn xmp_files_can_put_xmp(xf: *mut XmpFile, xmp: *const Xmp) -> bool;
pub fn xmp_files_can_put_xmp_xmpstring(xf: *mut XmpFile, xmp_packet: *const XmpString) -> bool;
pub fn xmp_files_can_put_xmp_cstr(
xf: *mut XmpFile,
xmp_packet: *const c_char,
len: size_t,
) -> bool;
pub fn xmp_files_put_xmp(xf: *mut XmpFile, xmp: *const Xmp) -> bool;
pub fn xmp_files_put_xmp_xmpstring(xf: *mut XmpFile, xmp_packet: *const XmpString) -> bool;
pub fn xmp_files_put_xmp_cstr(xf: *mut XmpFile, xmp_packet: *const c_char, len: size_t)
-> bool;
pub fn xmp_files_free(xf: *mut XmpFile) -> bool;
pub fn xmp_files_get_file_info(
xf: *mut XmpFile,
fp: *mut XmpString,
options: *mut u32, format: *mut FileType,
handler_flags: *mut u32, ) -> bool;
pub fn xmp_files_check_file_format(path: *const c_char) -> FileType;
pub fn xmp_files_get_format_info(
format: FileType,
options: *mut u32, ) -> bool;
pub fn xmp_register_namespace(
uri: *const c_char,
prefix: *const c_char,
reg_prefix: *mut XmpString,
) -> bool;
pub fn xmp_namespace_prefix(ns: *const c_char, prefix: *mut XmpString) -> bool;
pub fn xmp_prefix_namespace_uri(prefix: *const c_char, ns: *mut XmpString) -> bool;
pub fn xmp_new_empty() -> *mut Xmp;
pub fn xmp_new(buffer: *const c_char, len: size_t) -> *mut Xmp;
pub fn xmp_copy(xmp: *const Xmp) -> *mut Xmp;
pub fn xmp_free(xmp: *mut Xmp) -> bool;
pub fn xmp_parse(xmp: *mut Xmp, buffer: *const c_char, len: size_t) -> bool;
pub fn xmp_serialize(
xmp: *const Xmp,
buf: *mut XmpString,
options: u32, padding: u32,
) -> bool;
pub fn xmp_serialize_and_format(
xmp: *const Xmp,
buf: *mut XmpString,
options: u32, padding: u32,
newline: *const c_char,
tab: *const c_char,
indent: i32,
) -> bool;
pub fn xmp_get_property(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut XmpString,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_property_date(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut XmpDateTime,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_property_float(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut f64,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_property_bool(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut bool,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_property_int32(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut i32,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_property_int64(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
property: *mut i64,
propsbits: *mut u32, ) -> bool;
pub fn xmp_get_array_item(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
index: i32,
property: *mut XmpString,
propsbits: *mut u32, ) -> bool;
pub fn xmp_set_property(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: *const c_char,
optionbits: u32, ) -> bool;
pub fn xmp_set_property_date(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: *const XmpDateTime,
optionbits: u32, ) -> bool;
pub fn xmp_set_property_float(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: f64,
optionbits: u32, ) -> bool;
pub fn xmp_set_property_bool(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: bool,
optionbits: u32, ) -> bool;
pub fn xmp_set_property_int32(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: i32,
optionbits: u32, ) -> bool;
pub fn xmp_set_property_int64(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
value: i64,
optionbits: u32, ) -> bool;
pub fn xmp_set_array_item(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
index: i32,
value: *const c_char,
optionbits: u32, ) -> bool;
pub fn xmp_append_array_item(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
array_options: u32,
value: *const c_char,
optionbits: u32, ) -> bool;
pub fn xmp_delete_property(xmp: *mut Xmp, schema: *const c_char, name: *const c_char) -> bool;
pub fn xmp_has_property(xmp: *const Xmp, schema: *const c_char, name: *const c_char) -> bool;
pub fn xmp_get_localized_text(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
gen_lang: *const c_char,
spec_lang: *const c_char,
actual_lang: *mut XmpString,
value: *mut XmpString,
propbits: *mut u32, ) -> bool;
pub fn xmp_set_localized_text(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
gen_lang: *const c_char,
spec_lang: *const c_char,
value: *const c_char,
optionbits: u32, ) -> bool;
pub fn xmp_delete_localized_text(
xmp: *mut Xmp,
schema: *const c_char,
name: *const c_char,
gen_lang: *const c_char,
spec_lang: *const c_char,
) -> bool;
pub fn xmp_string_new() -> *mut XmpString;
pub fn xmp_string_free(s: *mut XmpString);
pub fn xmp_string_cstr(s: *const XmpString) -> *const c_char;
pub fn xmp_string_len(s: *const XmpString) -> size_t;
pub fn xmp_iterator_new(
xmp: *const Xmp,
schema: *const c_char,
name: *const c_char,
optionbits: u32, ) -> *mut XmpIterator;
pub fn xmp_iterator_free(i: *mut XmpIterator) -> bool;
pub fn xmp_iterator_next(
i: *mut XmpIterator,
schema: *mut XmpString,
name: *mut XmpString,
value: *mut XmpString,
option: *mut u32, ) -> bool;
pub fn xmp_iterator_skip(i: *mut XmpIterator, option: u32 ) -> bool;
pub fn xmp_datetime_compare(left: *const XmpDateTime, right: *const XmpDateTime) -> c_int;
}
#[cfg(test)]
#[test]
fn native_call_works() {
let inited = unsafe { xmp_init() };
assert!(inited);
let xf = unsafe { xmp_files_new() };
assert!(!xf.is_null());
assert!(unsafe { xmp_files_free(xf) });
assert!(unsafe { xmp_get_error() } == 0);
let xmp = unsafe { xmp_new_empty() };
let xmpiter =
unsafe { xmp_iterator_new(xmp, NS_DC.as_ptr(), "keywords".as_ptr() as *const c_char, 0) };
unsafe {
xmp_iterator_free(xmpiter);
}
unsafe {
xmp_free(xmp);
}
let xs = unsafe { xmp_string_new() };
assert!(!xs.is_null());
let s = unsafe { xmp_string_cstr(xs) };
assert!(!s.is_null());
unsafe {
xmp_string_free(xs);
}
unsafe {
xmp_terminate();
}
}