1#![allow(non_camel_case_types)]
6#![allow(dead_code)]
7
8use std::marker::{PhantomData, PhantomPinned};
9use std::os::raw::{c_char, c_int, c_ulong};
10
11#[macro_use]
12extern crate num_derive;
13
14pub type scf_version_t = c_ulong;
15
16pub const SCF_VERSION: scf_version_t = 1;
17
18pub const SCF_PG_FLAG_NONPERSISTENT: u32 = 0x1;
19
20pub const SMF_IMMEDIATE: c_int = 0x1;
24pub const SMF_TEMPORARY: c_int = 0x2;
25pub const SMF_AT_NEXT_BOOT: c_int = 0x4;
26
27macro_rules! opaque_handle {
28 ($type_name:ident) => {
29 #[repr(C)]
30 pub struct $type_name {
31 _data: [u8; 0],
32 _marker: PhantomData<(*mut u8, PhantomPinned)>,
38 }
39 impl Copy for $type_name {}
40 impl Clone for $type_name {
41 fn clone(&self) -> $type_name {
42 *self
43 }
44 }
45 };
46}
47
48opaque_handle!(scf_handle_t);
49opaque_handle!(scf_iter_t);
50opaque_handle!(scf_scope_t);
51opaque_handle!(scf_service_t);
52opaque_handle!(scf_instance_t);
53opaque_handle!(scf_snapshot_t);
54opaque_handle!(scf_propertygroup_t);
55opaque_handle!(scf_property_t);
56opaque_handle!(scf_value_t);
57opaque_handle!(scf_snaplevel_t);
58opaque_handle!(scf_transaction_t);
59opaque_handle!(scf_transaction_entry_t);
60
61#[derive(Debug, FromPrimitive, ToPrimitive)]
62#[repr(C)]
63pub enum scf_error_t {
64 SCF_ERROR_NONE = 1000, SCF_ERROR_NOT_BOUND, SCF_ERROR_NOT_SET, SCF_ERROR_NOT_FOUND, SCF_ERROR_TYPE_MISMATCH, SCF_ERROR_IN_USE, SCF_ERROR_CONNECTION_BROKEN, SCF_ERROR_INVALID_ARGUMENT, SCF_ERROR_NO_MEMORY, SCF_ERROR_CONSTRAINT_VIOLATED, SCF_ERROR_EXISTS, SCF_ERROR_NO_SERVER, SCF_ERROR_NO_RESOURCES, SCF_ERROR_PERMISSION_DENIED, SCF_ERROR_BACKEND_ACCESS, SCF_ERROR_HANDLE_MISMATCH, SCF_ERROR_HANDLE_DESTROYED, SCF_ERROR_VERSION_MISMATCH, SCF_ERROR_BACKEND_READONLY, SCF_ERROR_DELETED, SCF_ERROR_TEMPLATE_INVALID, SCF_ERROR_CALLBACK_FAILED = 1080, SCF_ERROR_INTERNAL = 1101, }
88
89#[derive(Debug, FromPrimitive, ToPrimitive, Clone, Copy)]
90#[repr(C)]
91pub enum scf_type_t {
92 SCF_TYPE_INVALID = 0,
93
94 SCF_TYPE_BOOLEAN,
95 SCF_TYPE_COUNT,
96 SCF_TYPE_INTEGER,
97 SCF_TYPE_TIME,
98 SCF_TYPE_ASTRING,
99 SCF_TYPE_OPAQUE,
100
101 SCF_TYPE_USTRING = 100,
102
103 SCF_TYPE_URI = 200,
104 SCF_TYPE_FMRI,
105
106 SCF_TYPE_HOST = 300,
107 SCF_TYPE_HOSTNAME,
108 SCF_TYPE_NET_ADDR_V4,
109 SCF_TYPE_NET_ADDR_V6,
110 SCF_TYPE_NET_ADDR,
111}
112
113pub const SCF_LIMIT_MAX_NAME_LENGTH: u32 = 0xfffff830;
114pub const SCF_LIMIT_MAX_VALUE_LENGTH: u32 = 0xfffff82f;
115pub const SCF_LIMIT_MAX_PG_TYPE_LENGTH: u32 = 0xfffff82e;
116pub const SCF_LIMIT_MAX_FMRI_LENGTH: u32 = 0xfffff82d;
117
118pub const SCF_SCOPE_LOCAL: &[u8] = b"localhost\0";
119
120pub const SCF_DECODE_FMRI_EXACT: c_int = 0x00000001;
121pub const SCF_DECODE_FMRI_TRUNCATE: c_int = 0x00000002;
122pub const SCF_DECODE_FMRI_REQUIRE_INSTANCE: c_int = 0x00000004;
123pub const SCF_DECODE_FMRI_REQUIRE_NO_INSTANCE: c_int = 0x00000008;
124
125pub const SCF_DECORATE_CLEAR: *mut scf_value_t = std::ptr::null_mut();
126
127pub mod decorations {
128 pub const DEBUG: &[u8] = b"debug\0";
132
133 pub const ZONE: &[u8] = b"zone\0";
138}
139
140#[cfg(target_os = "illumos")]
141mod native;
142#[cfg(target_os = "illumos")]
143pub use native::*;
144
145#[cfg(not(target_os = "illumos"))]
146mod stubs;
147#[cfg(not(target_os = "illumos"))]
148pub use stubs::*;