summaryrefslogtreecommitdiff
path: root/libsyslog-sys
diff options
context:
space:
mode:
Diffstat (limited to 'libsyslog-sys')
-rw-r--r--libsyslog-sys/Cargo.toml7
-rw-r--r--libsyslog-sys/README.md23
-rw-r--r--libsyslog-sys/build.rs29
-rw-r--r--libsyslog-sys/src/lib.rs46
-rw-r--r--libsyslog-sys/wrapper.h1
5 files changed, 97 insertions, 9 deletions
diff --git a/libsyslog-sys/Cargo.toml b/libsyslog-sys/Cargo.toml
index ff5838d..160e575 100644
--- a/libsyslog-sys/Cargo.toml
+++ b/libsyslog-sys/Cargo.toml
@@ -1,9 +1,12 @@
[package]
name = "libsyslog-sys"
-version = "0.0.0"
+version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
description = "FFI bindings to system's native syslog"
-repository = "https://git.netizen.se/libsyslog-rs"
+repository = "https://git.netizen.se/libsyslog-rs/"
keywords = [ "ffi", "logging", "syslog" ]
categories = [ "external-ffi-bindings", "os" ]
+
+[build-dependencies]
+bindgen = "0.64.0"
diff --git a/libsyslog-sys/README.md b/libsyslog-sys/README.md
index a0e6541..c5bd32f 100644
--- a/libsyslog-sys/README.md
+++ b/libsyslog-sys/README.md
@@ -1,11 +1,10 @@
libsyslog-sys
=============
-The code (to be publiced shortly) in this crate provides a low level API to the
-system's native syslog, the one typically implemented in C and residing in
-libc.
+The code in this crate provides a low level API to the system's native syslog,
+the one typically implemented in C and residing in libc.
Most users are likely more interested in the higher level safe API in the
-libsyslog crate.
+[libsyslog][] crate.
Contact
-------
@@ -13,9 +12,19 @@ Please see <https://www.netizen.se/#contact>.
Copyright and License
---------------------
-This crate is Copyright 2023 Martin Samuelsson. It is distributed under the
-terms of both the MIT license and the Apache License (Version 2.0).
+This crate is Copyright 2023 Martin Samuelsson. It is licensed under either of
-See LICENSE-APACHE and LICENSE-MIT for details.
+ * Apache License, Version 2.0
+ ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
+ * MIT license
+ ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
+
+at your option.
+
+## Contribution
+
+Unless you explicitly state otherwise, any contribution intentionally submitted
+for inclusion in the work by you, as defined in the Apache-2.0 license, shall be
+dual licensed as above, without any additional terms or conditions.
[libsyslog]: https://lib.rs/crates/libsyslog
diff --git a/libsyslog-sys/build.rs b/libsyslog-sys/build.rs
new file mode 100644
index 0000000..6cab3c4
--- /dev/null
+++ b/libsyslog-sys/build.rs
@@ -0,0 +1,29 @@
+extern crate bindgen;
+
+use {
+ bindgen::{
+ Builder,
+ CargoCallbacks,
+ MacroTypeVariation,
+ },
+ std::{
+ env,
+ path::PathBuf,
+ },
+};
+
+fn main() {
+ println!("cargo:rerun-if-changed=wrapper.h");
+
+ let bindings = Builder::default()
+ .header("wrapper.h")
+ .parse_callbacks(Box::new(CargoCallbacks))
+ .default_macro_constant_type(MacroTypeVariation::Signed)
+ .generate()
+ .expect("Unable to generate bindings");
+
+ let out_path = PathBuf::from(env::var("OUT_DIR").unwrap());
+ bindings
+ .write_to_file(out_path.join("bindings.rs"))
+ .expect("Couldn't write bindings!");
+}
diff --git a/libsyslog-sys/src/lib.rs b/libsyslog-sys/src/lib.rs
index e69de29..ed4ef3d 100644
--- a/libsyslog-sys/src/lib.rs
+++ b/libsyslog-sys/src/lib.rs
@@ -0,0 +1,46 @@
+#![allow(non_upper_case_globals)]
+#![allow(non_camel_case_types)]
+#![allow(non_snake_case)]
+
+//! The code in this crate contains the raw bindings for syslog, automatically
+//! generated by [bindgen][]. Before continuing any further, please make sure
+//! [libsyslog][] is not the crate you really are looking for.
+//!
+//! See [The Open Group Base Specifications Issue 7, 2018 edition][0] for
+//! actual API documentation or [Wikipedia][1] for general context.
+//!
+//! Implementation specific documentation: (verified working platforms)
+//!
+//! * [FreeBSD][]
+//! * [Haiku][]
+//! * [illumos][]
+//! * [Linux][] (with glibc)
+//! * [NetBSD][]
+//! * [OpenBSD][]
+//!
+//! [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=syslog
+//! [Haiku]: https://www.haiku-os.org/documents/dev/system_logging
+//! [illumos]: https://illumos.org/man/3C/syslog
+//! [Linux]: https://www.man7.org/linux/man-pages/man3/syslog.3.html
+//! [NetBSD]: https://man.netbsd.org/syslog.3
+//! [OpenBSD]: https://man.openbsd.org/syslog.3
+//!
+//! Apple Inc. is advising to no longer use syslog on [macOS][] 10.12 and
+//! later, yet this crate compiles and messages produced by it do appear in the
+//! output of `log stream` on such platforms.
+//!
+//! [macOS]: https://developer.apple.com/documentation/os/logging
+//!
+//! [bindgen]: https://docs.rs/bindgen/latest/bindgen/
+//! [libsyslog]: https://docs.rs/bindgen/latest/libsyslog/
+//! [0]: https://pubs.opengroup.org/onlinepubs/9699919799/functions/syslog.html
+//! [1]: https://en.wikipedia.org/wiki/Syslog
+//
+// Rust tiers are at: <https://doc.rust-lang.org/rustc/platform-support.html>
+// It appears at least AIX and QNX should likely support syslog. Please get in
+// touch if having access to such systems.
+//
+// [AIX]: https://www.ibm.com/docs/en/aix/latest?topic=s-syslog-openlog-closelog-setlogmask-subroutine
+// [QNX]: https://www.qnx.com/developers/docs/7.1/com.qnx.doc.neutrino.lib_ref/topic/s/syslog.html
+
+include!(concat!(env!("OUT_DIR"), "/bindings.rs"));
diff --git a/libsyslog-sys/wrapper.h b/libsyslog-sys/wrapper.h
new file mode 100644
index 0000000..7761ece
--- /dev/null
+++ b/libsyslog-sys/wrapper.h
@@ -0,0 +1 @@
+#include <syslog.h>