flips_sys/
ups.rs

1//! Bindings to `libups.h` to work with UPS patches.
2
3#![allow(bad_style)]
4
5use super::mem;
6
7#[repr(C)]
8#[derive(Clone, Debug, PartialEq)]
9pub enum upserror {
10    /// Patch applied or created successfully.
11    ups_ok,
12    /// Unused, equivalent to `bps_to_output`.
13    ups_unused1,
14    /// Not the intended input file for this patch.
15    ups_not_this,
16    /// Not a UPS patch, or it's malformed somehow.
17    ups_broken,
18    /// Unused, equivalentto `bps_io`.
19    ups_unused2,
20    /// The input files are identical.
21    ups_identical,
22    /// Somehow, you're asking for something a `size_t` can't represent.
23    ups_too_big,
24    /// Unused, equivalent to `bps_out_of_mem`.
25    ups_unused3,
26    /// Unused, equivalent to `bps_canceled`.
27    ups_unused4,
28    /// Unused, just kill GCC warning.
29    ups_shut_up_gcc,
30}
31
32#[link(name = "ups")]
33extern "C" {
34    /// Applies the UPS patch in `patch` to `in_` and stores it to `out`.
35    ///
36    /// Send the return value in out to `ups_free` when you're done with it.
37    pub fn ups_apply(patch: mem, in_: mem, out: *mut mem) -> upserror;
38
39    /// Creates an UPS patch that converts `source` to `target` and stores it to `patch`.
40    ///
41    /// Currently not implemented, will return an error everytime.
42    pub fn ups_create(source: mem, target: mem, patch: *mut mem) -> upserror;
43
44    /// Frees the memory returned in the output parameters of the above.
45    ///
46    /// Do not call it twice on the same input, nor on anything you got from
47    /// anywhere else. `ups_free` is guaranteed to be equivalent to calling
48    /// `free` from `<stdlib.h>` on `mem.ptr`.
49    pub fn ups_free(mem: mem);
50}