Skip to content

Fix c_str redesign errors #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Jan 12, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/Cargo.lock
/target
*.sublime-workspace
*.swp
120 changes: 60 additions & 60 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@
//! [inotify(7)]: http://man7.org/linux/man-pages/man7/inotify.7.html

use libc::{
c_char,
c_int,
uint32_t };
c_char,
c_int,
uint32_t };


pub use libc::close;
Expand Down Expand Up @@ -185,9 +185,9 @@ pub const IN_CLOSE: uint32_t = (IN_CLOSE_WRITE | IN_CLOSE_NOWRITE);

/// Event: Any event occured.
pub const IN_ALL_EVENTS: uint32_t = (
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_CLOSE_NOWRITE
| IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE | IN_DELETE
| IN_DELETE_SELF | IN_MOVE_SELF);
IN_ACCESS | IN_MODIFY | IN_ATTRIB | IN_CLOSE_WRITE | IN_CLOSE_NOWRITE
| IN_OPEN | IN_MOVED_FROM | IN_MOVED_TO | IN_CREATE | IN_DELETE
| IN_DELETE_SELF | IN_MOVE_SELF);

/// Option: Don't watch children (if self is a directory).
pub const IN_ONLYDIR : uint32_t = 0x01000000;
Expand Down Expand Up @@ -257,64 +257,64 @@ pub const IN_IGNORED : uint32_t = 0x00008000;
/// [read(2)]: http://man7.org/linux/man-pages/man2/read.2.html
/// [signal(7)]: http://man7.org/linux/man-pages/man2/read.2.html
#[allow(non_camel_case_types)]
#[allow(raw_pointer_deriving)]
#[allow(raw_pointer_derive)]
#[derive(Copy, Show)]
pub struct inotify_event {
/// Identifies the watch for which this event occurs.
///
/// It is one of the watch descriptors returned by a previous call
/// to `inotify_add_watch()`.
pub wd : c_int,

/// Contains bits that describe the event that occurred.
pub mask : uint32_t,

/// A unique integer that connects related events.
///
/// Currently used only for rename events. A related pair of
/// IN_MOVED_FROM and IN_MOVED_TO events will have the same,
/// non-zero, cookie. For all other events, cookie is 0.
pub cookie: uint32_t,

/// The length of `name`.
///
/// Used to determine the size of this structure. When `name`
/// isn't present (`name` is only present when an event occurs
/// for a file inside a watched directory), it is 0. When `name`
/// *is* present, it counts all of `name`'s bytes, including `\0`.
///
/// > The `name` field is present only when an event is returned for
/// > a file inside a watched directory; it identifies the file
/// > pathname relative to the watched directory. This pathname is
/// > null-terminated, and may include further null bytes ('\0') to
/// > align subsequent reads to a suitable address boundary.
///
/// The `name` field must be ommited in this definition.
pub len : uint32_t,
/// Identifies the watch for which this event occurs.
///
/// It is one of the watch descriptors returned by a previous call
/// to `inotify_add_watch()`.
pub wd : c_int,

/// Contains bits that describe the event that occurred.
pub mask : uint32_t,

/// A unique integer that connects related events.
///
/// Currently used only for rename events. A related pair of
/// IN_MOVED_FROM and IN_MOVED_TO events will have the same,
/// non-zero, cookie. For all other events, cookie is 0.
pub cookie: uint32_t,

/// The length of `name`.
///
/// Used to determine the size of this structure. When `name`
/// isn't present (`name` is only present when an event occurs
/// for a file inside a watched directory), it is 0. When `name`
/// *is* present, it counts all of `name`'s bytes, including `\0`.
///
/// > The `name` field is present only when an event is returned for
/// > a file inside a watched directory; it identifies the file
/// > pathname relative to the watched directory. This pathname is
/// > null-terminated, and may include further null bytes ('\0') to
/// > align subsequent reads to a suitable address boundary.
///
/// The `name` field must be ommited in this definition.
pub len : uint32_t,
}


extern {
/// Creates an inotify instance.
///
/// Returns a file descriptor referring to the inotify instance.
pub fn inotify_init() -> c_int;

/// Creates an inotify instance.
///
/// Also takes a bit mask of flags that provide access to extra
/// functionality. Returns a file descriptor.
pub fn inotify_init1(flags: c_int) -> c_int;

/// Manipulates the "watch list" associated with an inotify instance.
///
/// > Each item ("watch") in the watch list specifies the pathname of
/// > a file or directory, along with some set of events that the kernel
/// > should monitor for the file referred to by that pathname.
///
/// This function either creates a new watch, or modifies an existing one.
pub fn inotify_add_watch(fd: c_int, pathname: *const c_char, mask: uint32_t) -> c_int;

/// Removes an item from an inotify watch list.
pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int;
/// Creates an inotify instance.
///
/// Returns a file descriptor referring to the inotify instance.
pub fn inotify_init() -> c_int;

/// Creates an inotify instance.
///
/// Also takes a bit mask of flags that provide access to extra
/// functionality. Returns a file descriptor.
pub fn inotify_init1(flags: c_int) -> c_int;

/// Manipulates the "watch list" associated with an inotify instance.
///
/// > Each item ("watch") in the watch list specifies the pathname of
/// > a file or directory, along with some set of events that the kernel
/// > should monitor for the file referred to by that pathname.
///
/// This function either creates a new watch, or modifies an existing one.
pub fn inotify_add_watch(fd: c_int, pathname: *const c_char, mask: uint32_t) -> c_int;

/// Removes an item from an inotify watch list.
pub fn inotify_rm_watch(fd: c_int, wd: c_int) -> c_int;
}
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
//! [wiki]: https://en.wikipedia.org/wiki/Inotify
//! [inotify7]: http://man7.org/linux/man-pages/man7/inotify.7.html

#[allow(unstable)]
extern crate libc;

pub use wrapper::INotify;
Expand Down
Loading