Skip to content

Commit 4fc03fe

Browse files
committed
Auto merge of rust-lang#278 - lemonrock:syslog, r=alexcrichton
Adding syslog functions, constants and structs This commit adds the functions:- - syslog - openlog - closelog - setlogmask It adds LOG_* constants. It adds the `CODE` struct used by the `#define` definitions `prioritynames` and `facilitynames`. It does not add:- - the function `vsyslog`; this is an extension to POSIX and uses va_list macros; - the `#define`s `prioritynames` and `facilitynames`, as usage is not common - rust functions mirroring the macros:- - LOG_PRI - LOG_MAKEPRI - LOG_MASK - LOG_UPTO - LOG_FAC * `CODE` is included in case a third-party unsafe C function returns or takes it.
2 parents ac75250 + 828766f commit 4fc03fe

File tree

9 files changed

+70
-0
lines changed

9 files changed

+70
-0
lines changed

Diff for: libc-test/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ fn main() {
9595
cfg.header("sched.h");
9696
cfg.header("termios.h");
9797
cfg.header("poll.h");
98+
cfg.header("syslog.h");
9899
}
99100

100101
if android {

Diff for: src/unix/bsd/apple/mod.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,13 @@ pub const RTLD_GLOBAL: ::c_int = 0x8;
10291029

10301030
pub const _WSTOPPED: ::c_int = 0o177;
10311031

1032+
pub const LOG_NETINFO: ::c_int = 12 << 3;
1033+
pub const LOG_REMOTEAUTH: ::c_int = 13 << 3;
1034+
pub const LOG_INSTALL: ::c_int = 14 << 3;
1035+
pub const LOG_RAS: ::c_int = 15 << 3;
1036+
pub const LOG_LAUNCHD: ::c_int = 24 << 3;
1037+
pub const LOG_NFACILITIES: ::c_int = 25;
1038+
10321039
f! {
10331040
pub fn WSTOPSIG(status: ::c_int) -> ::c_int {
10341041
status >> 8

Diff for: src/unix/bsd/freebsdlike/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,11 @@ pub const RTLD_NODELETE: ::c_int = 0x1000;
665665
pub const RTLD_NOLOAD: ::c_int = 0x2000;
666666
pub const RTLD_GLOBAL: ::c_int = 0x100;
667667

668+
pub const LOG_NTP: ::c_int = 12 << 3;
669+
pub const LOG_SECURITY: ::c_int = 13 << 3;
670+
pub const LOG_CONSOLE: ::c_int = 14 << 3;
671+
pub const LOG_NFACILITIES: ::c_int = 24;
672+
668673
#[link(name = "util")]
669674
extern {
670675
pub fn getnameinfo(sa: *const ::sockaddr,

Diff for: src/unix/bsd/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,11 @@ pub const WNOHANG: ::c_int = 1;
293293
pub const RTLD_NOW: ::c_int = 0x2;
294294
pub const RTLD_DEFAULT: *mut ::c_void = -2isize as *mut ::c_void;
295295

296+
pub const LOG_CRON: ::c_int = 9 << 3;
297+
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
298+
pub const LOG_FTP: ::c_int = 11 << 3;
299+
pub const LOG_PERROR: ::c_int = 0x20;
300+
296301
f! {
297302
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
298303
let bits = mem::size_of_val(&(*set).fds_bits[0]) * 8;

Diff for: src/unix/bsd/openbsdlike/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -445,6 +445,8 @@ pub const Q_SETQUOTA: ::c_int = 0x400;
445445

446446
pub const RTLD_GLOBAL: ::c_int = 0x100;
447447

448+
pub const LOG_NFACILITIES: ::c_int = 24;
449+
448450
#[link(name = "util")]
449451
extern {
450452
pub fn mincore(addr: *mut ::c_void, len: ::size_t,

Diff for: src/unix/mod.rs

+41
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,42 @@ pub const IF_NAMESIZE: ::size_t = 16;
145145

146146
pub const RTLD_LAZY: ::c_int = 0x1;
147147

148+
pub const LOG_EMERG: ::c_int = 0;
149+
pub const LOG_ALERT: ::c_int = 1;
150+
pub const LOG_CRIT: ::c_int = 2;
151+
pub const LOG_ERR: ::c_int = 3;
152+
pub const LOG_WARNING: ::c_int = 4;
153+
pub const LOG_NOTICE: ::c_int = 5;
154+
pub const LOG_INFO: ::c_int = 6;
155+
pub const LOG_DEBUG: ::c_int = 7;
156+
157+
pub const LOG_KERN: ::c_int = 0;
158+
pub const LOG_USER: ::c_int = 1 << 3;
159+
pub const LOG_MAIL: ::c_int = 2 << 3;
160+
pub const LOG_DAEMON: ::c_int = 3 << 3;
161+
pub const LOG_AUTH: ::c_int = 4 << 3;
162+
pub const LOG_SYSLOG: ::c_int = 5 << 3;
163+
pub const LOG_LPR: ::c_int = 6 << 3;
164+
pub const LOG_NEWS: ::c_int = 7 << 3;
165+
pub const LOG_UUCP: ::c_int = 8 << 3;
166+
pub const LOG_LOCAL0: ::c_int = 16 << 3;
167+
pub const LOG_LOCAL1: ::c_int = 17 << 3;
168+
pub const LOG_LOCAL2: ::c_int = 18 << 3;
169+
pub const LOG_LOCAL3: ::c_int = 19 << 3;
170+
pub const LOG_LOCAL4: ::c_int = 20 << 3;
171+
pub const LOG_LOCAL5: ::c_int = 21 << 3;
172+
pub const LOG_LOCAL6: ::c_int = 22 << 3;
173+
pub const LOG_LOCAL7: ::c_int = 23 << 3;
174+
175+
pub const LOG_PID: ::c_int = 0x01;
176+
pub const LOG_CONS: ::c_int = 0x02;
177+
pub const LOG_ODELAY: ::c_int = 0x04;
178+
pub const LOG_NDELAY: ::c_int = 0x08;
179+
pub const LOG_NOWAIT: ::c_int = 0x10;
180+
181+
pub const LOG_PRIMASK: ::c_int = 7;
182+
pub const LOG_FACMASK: ::c_int = 0x3f8;
183+
148184
cfg_if! {
149185
if #[cfg(dox)] {
150186
// on dox builds don't pull in anything
@@ -732,6 +768,11 @@ extern {
732768
pub fn mkdtemp(template: *mut ::c_char) -> *mut ::c_char;
733769
pub fn futimes(fd: ::c_int, times: *const ::timeval) -> ::c_int;
734770
pub fn nl_langinfo(item: ::nl_item) -> *mut ::c_char;
771+
772+
pub fn openlog(ident: *const ::c_char, logopt: ::c_int, facility: ::c_int);
773+
pub fn closelog();
774+
pub fn setlogmask(maskpri: ::c_int) -> ::c_int;
775+
pub fn syslog(priority: ::c_int, message: *const ::c_char, ...);
735776
}
736777

737778
cfg_if! {

Diff for: src/unix/notbsd/linux/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -447,6 +447,8 @@ pub const NCCS: usize = 32;
447447

448448
pub const AF_NETLINK: ::c_int = 16;
449449

450+
pub const LOG_NFACILITIES: ::c_int = 24;
451+
450452
f! {
451453
pub fn CPU_ZERO(cpuset: &mut cpu_set_t) -> () {
452454
for slot in cpuset.bits.iter_mut() {

Diff for: src/unix/notbsd/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -645,6 +645,11 @@ pub const POSIX_FADV_NOREUSE: ::c_int = 5;
645645
pub const AT_FDCWD: ::c_int = -100;
646646
pub const AT_SYMLINK_NOFOLLOW: ::c_int = 0x100;
647647

648+
pub const LOG_CRON: ::c_int = 9 << 3;
649+
pub const LOG_AUTHPRIV: ::c_int = 10 << 3;
650+
pub const LOG_FTP: ::c_int = 11 << 3;
651+
pub const LOG_PERROR: ::c_int = 0x20;
652+
648653
f! {
649654
pub fn FD_CLR(fd: ::c_int, set: *mut fd_set) -> () {
650655
let fd = fd as usize;

Diff for: src/unix/solaris/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -806,6 +806,8 @@ pub const _RWL_MAGIC: u16 = 0x5257; // RW
806806

807807
pub const NCCS: usize = 19;
808808

809+
pub const LOG_CRON: ::c_int = 15 << 3;
810+
809811
pub const PTHREAD_MUTEX_INITIALIZER: pthread_mutex_t = pthread_mutex_t {
810812
__pthread_mutex_flag1: 0,
811813
__pthread_mutex_flag2: 0,

0 commit comments

Comments
 (0)