-- cgit 1.4.1 From 0e6d521ae0970669e9943231db837de6fb068a9d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 13:11:33 +0200 Subject: chore: Add project bootstrap files --- CODE_OF_CONDUCT.md | 20 ++++++++++++++++++++ LICENSE | 21 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 CODE_OF_CONDUCT.md create mode 100644 LICENSE diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000000..c4013ac13e --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,20 @@ +A SERMON ON ETHICS AND LOVE +=========================== + +One day Mal-2 asked the messenger spirit Saint Gulik to approach the Goddess and request Her presence for some desperate advice. Shortly afterwards the radio came on by itself, and an ethereal female Voice said **YES?** + +"O! Eris! Blessed Mother of Man! Queen of Chaos! Daughter of Discord! Concubine of Confusion! O! Exquisite Lady, I beseech You to lift a heavy burden from my heart!" + +**WHAT BOTHERS YOU, MAL? YOU DON'T SOUND WELL.** + +"I am filled with fear and tormented with terrible visions of pain. Everywhere people are hurting one another, the planet is rampant with injustices, whole societies plunder groups of their own people, mothers imprison sons, children perish while brothers war. O, woe." + +**WHAT IS THE MATTER WITH THAT, IF IT IS WHAT YOU WANT TO DO?** + +"But nobody Wants it! Everybody hates it." + +**OH. WELL, THEN *STOP*.** + +At which moment She turned herself into an aspirin commercial and left The Polyfather stranded alone with his species. + +SINISTER DEXTER HAS A BROKEN SPIROMETER. diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000000..0feedcb4bb --- /dev/null +++ b/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) 2017 Langler AS + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. -- cgit 1.4.1 From 10dcab636583a65e58a979016683b2fae7a9a62f Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 12:06:17 +0200 Subject: feat: Add command to list and inspect queues --- .gitignore | 4 ++ Cargo.lock | 176 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 8 +++ src/main.rs | 64 ++++++++++++++++++++++ 4 files changed, 252 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000000..5bd19a47c3 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +/target/ +**/*.rs.bk +.idea/ +*.iml diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000000..54a0009e24 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,176 @@ +[root] +name = "mq" +version = "0.1.0" +dependencies = [ + "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", + "posix_mq 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "ansi_term" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "atty" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "bitflags" +version = "0.9.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "clap" +version = "2.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", + "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "kernel32-sys" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "libc" +version = "0.2.32" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "nix" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "posix_mq" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "redox_syscall" +version = "0.1.31" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "strsim" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "term_size" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "termion" +version = "1.5.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "textwrap" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "unicode-width" +version = "0.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "vec_map" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "void" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-build" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[metadata] +"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" +"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" +"checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" +"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" +"checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" +"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" +"checksum libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "56cce3130fd040c28df6f495c8492e5ec5808fb4c9093c310df02b0c8f030148" +"checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32" +"checksum posix_mq 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ab51dbacda5aa610638256f89eb913747cc4156113f0a4df8619ae05d7549f5" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" +"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" +"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" +"checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" +"checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" +"checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" +"checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" +"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000000..73d087f69b --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "mq" +version = "0.1.0" +authors = ["Vincent Ambo "] + +[dependencies] +posix_mq = "0.1.1" +clap = "2.26.2" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000000..8cc30424a0 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,64 @@ +extern crate clap; +extern crate posix_mq; + +use clap::{App, SubCommand, Arg, AppSettings}; +use posix_mq::{Name, Queue}; + +fn run_ls() { + use std::fs::{read_dir, File}; + use std::io::Read; + + let mqueues = read_dir("/dev/mqueue") + .expect("Could not read message queues"); + + mqueues.for_each(|queue| { + //let queue_name = (&queue.unwrap().file_name()).into_string().unwrap(); + let path = queue.unwrap().path(); + let status = { + let mut file = File::open(&path) + .expect("Could not open queue file"); + + let mut content = String::new(); + file.read_to_string(&mut content).expect("Could not read queue file"); + + content + }; + + let queue_name = path.components().last().unwrap().as_os_str(); + println!("{:?}: {}", queue_name, status) + }); +} + +fn run_inspect(queue_name: &str) { + let name = Name::new(queue_name).expect("Invalid queue name"); + let queue = Queue::open(name).expect("Could not open queue"); + + println!("Queue {}:\n", queue_name); + println!("Max. message size: {} bytes", queue.max_size()); + println!("Max. # of pending messages: {}", queue.max_pending()); +} + +fn main() { + let ls = SubCommand::with_name("ls").about("list message queues"); + let inspect = SubCommand::with_name("inspect") + .about("inspect details about a queue") + .arg(Arg::with_name("queue") + .short("q") + .required(true) + .takes_value(true)); + + + let matches = App::new("mq") + .setting(AppSettings::SubcommandRequiredElseHelp) + .version("0.0.1") + .about("Administrate and inspect POSIX message queues") + .subcommand(ls) + .subcommand(inspect) + .get_matches(); + + match matches.subcommand() { + ("ls", _) => run_ls(), + ("inspect", Some(cmd)) => run_inspect(cmd.value_of("queue").unwrap()), + _ => unimplemented!(), + } +} -- cgit 1.4.1 From 44e72884a6e2a8a5f2c25aeb1e1063eba5d32cfb Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 13:03:00 +0200 Subject: feat: Add create command Adds a command to create message queues with custom parameters. --- src/main.rs | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8cc30424a0..ee4e7ad231 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,18 +1,18 @@ extern crate clap; extern crate posix_mq; -use clap::{App, SubCommand, Arg, AppSettings}; +use clap::{App, SubCommand, Arg, ArgMatches, AppSettings}; use posix_mq::{Name, Queue}; +use std::fs::{read_dir, File}; +use std::io::Read; +use std::process::exit; fn run_ls() { - use std::fs::{read_dir, File}; - use std::io::Read; let mqueues = read_dir("/dev/mqueue") .expect("Could not read message queues"); mqueues.for_each(|queue| { - //let queue_name = (&queue.unwrap().file_name()).into_string().unwrap(); let path = queue.unwrap().path(); let status = { let mut file = File::open(&path) @@ -38,6 +38,24 @@ fn run_inspect(queue_name: &str) { println!("Max. # of pending messages: {}", queue.max_pending()); } +fn run_create(cmd: &ArgMatches) { + let name = Name::new(cmd.value_of("queue").unwrap()) + .expect("Invalid queue name"); + + let max_pending: i64 = cmd.value_of("max-pending").unwrap().parse().unwrap(); + let max_size: i64 = cmd.value_of("max-size").unwrap().parse().unwrap(); + + let queue = Queue::create(name, max_pending, max_size * 1024); + + match queue { + Ok(_) => println!("Queue created successfully"), + Err(e) => { + println!("Could not create queue: {}", e); + exit(1); + }, + }; +} + fn main() { let ls = SubCommand::with_name("ls").about("list message queues"); let inspect = SubCommand::with_name("inspect") @@ -47,6 +65,20 @@ fn main() { .required(true) .takes_value(true)); + let create = SubCommand::with_name("create") + .about("Create a new queue") + .arg(Arg::with_name("queue") + .required(true) + .takes_value(true)) + .arg(Arg::with_name("max-size") + .help("maximum message size (in kB)") + .required(true) + .takes_value(true)) + .arg(Arg::with_name("max-pending") + .help("maximum # of pending messages") + .required(true) + .takes_value(true)); + let matches = App::new("mq") .setting(AppSettings::SubcommandRequiredElseHelp) @@ -54,11 +86,13 @@ fn main() { .about("Administrate and inspect POSIX message queues") .subcommand(ls) .subcommand(inspect) + .subcommand(create) .get_matches(); match matches.subcommand() { ("ls", _) => run_ls(), ("inspect", Some(cmd)) => run_inspect(cmd.value_of("queue").unwrap()), + ("create", Some(cmd)) => run_create(cmd), _ => unimplemented!(), } } -- cgit 1.4.1 From 79a27f8f0d5251cde3d1577665285a79da59880a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 13:06:40 +0200 Subject: feat(build): Add Travis-CI configuration --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000000..a493f815a9 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,3 @@ +language: rust +rust: + - stable -- cgit 1.4.1 From 23ac0eef87811271a1e0b4072ed1fe7161fb6142 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 13:13:29 +0200 Subject: refactor: More sensible CLI structure --- src/main.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index ee4e7ad231..006ae5c4f7 100644 --- a/src/main.rs +++ b/src/main.rs @@ -61,7 +61,6 @@ fn main() { let inspect = SubCommand::with_name("inspect") .about("inspect details about a queue") .arg(Arg::with_name("queue") - .short("q") .required(true) .takes_value(true)); @@ -72,10 +71,12 @@ fn main() { .takes_value(true)) .arg(Arg::with_name("max-size") .help("maximum message size (in kB)") + .long("max-size") .required(true) .takes_value(true)) .arg(Arg::with_name("max-pending") .help("maximum # of pending messages") + .long("max-pending") .required(true) .takes_value(true)); -- cgit 1.4.1 From a023e05474536e9397bd4e3bf1ddf32e20366ff9 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 16:29:53 +0200 Subject: feat: Add receive command Adds a command to receive a single message from a queue. --- src/main.rs | 45 ++++++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/main.rs b/src/main.rs index 006ae5c4f7..08595d9655 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,11 +4,10 @@ extern crate posix_mq; use clap::{App, SubCommand, Arg, ArgMatches, AppSettings}; use posix_mq::{Name, Queue}; use std::fs::{read_dir, File}; -use std::io::Read; +use std::io::{self, Read, Write}; use std::process::exit; fn run_ls() { - let mqueues = read_dir("/dev/mqueue") .expect("Could not read message queues"); @@ -50,25 +49,47 @@ fn run_create(cmd: &ArgMatches) { match queue { Ok(_) => println!("Queue created successfully"), Err(e) => { - println!("Could not create queue: {}", e); + writeln!(io::stderr(), "Could not create queue: {}", e).ok(); exit(1); }, }; } +fn run_receive(queue_name: &str) { + let name = Name::new(queue_name).expect("Invalid queue name"); + let queue = Queue::open(name).expect("Could not open queue"); + + let message = match queue.receive() { + Ok(msg) => msg, + Err(e) => { + writeln!(io::stderr(), "Failed to receive message: {}", e).ok(); + exit(1); + } + }; + + // Attempt to write the message out as a string, but write out raw bytes if it turns out to not + // be UTF-8 encoded data. + match String::from_utf8(message.data.clone()) { + Ok(string) => println!("{}", string), + Err(_) => { + writeln!(io::stderr(), "Message not UTF-8 encoded!").ok(); + io::stdout().write(message.data.as_ref()).ok(); + } + }; +} + fn main() { let ls = SubCommand::with_name("ls").about("list message queues"); + + let queue_arg = Arg::with_name("queue").required(true).takes_value(true); + let inspect = SubCommand::with_name("inspect") .about("inspect details about a queue") - .arg(Arg::with_name("queue") - .required(true) - .takes_value(true)); + .arg(&queue_arg); let create = SubCommand::with_name("create") .about("Create a new queue") - .arg(Arg::with_name("queue") - .required(true) - .takes_value(true)) + .arg(&queue_arg) .arg(Arg::with_name("max-size") .help("maximum message size (in kB)") .long("max-size") @@ -80,6 +101,10 @@ fn main() { .required(true) .takes_value(true)); + let receive = SubCommand::with_name("receive") + .about("Receive a message from a queue") + .arg(&queue_arg); + let matches = App::new("mq") .setting(AppSettings::SubcommandRequiredElseHelp) @@ -88,12 +113,14 @@ fn main() { .subcommand(ls) .subcommand(inspect) .subcommand(create) + .subcommand(receive) .get_matches(); match matches.subcommand() { ("ls", _) => run_ls(), ("inspect", Some(cmd)) => run_inspect(cmd.value_of("queue").unwrap()), ("create", Some(cmd)) => run_create(cmd), + ("receive", Some(cmd)) => run_receive(cmd.value_of("queue").unwrap()), _ => unimplemented!(), } } -- cgit 1.4.1 From d742c6526b72d34dc6a540f8e0d1b5c91171ae2a Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 16:36:01 +0200 Subject: feat: Add send command Adds a command that can be used to send simple messages. In the future this may also accept arguments from stdin to send non-text messages. --- src/main.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 08595d9655..634d98f900 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,7 @@ extern crate clap; extern crate posix_mq; use clap::{App, SubCommand, Arg, ArgMatches, AppSettings}; -use posix_mq::{Name, Queue}; +use posix_mq::{Name, Queue, Message}; use std::fs::{read_dir, File}; use std::io::{self, Read, Write}; use std::process::exit; @@ -78,6 +78,24 @@ fn run_receive(queue_name: &str) { }; } +fn run_send(queue_name: &str, content: &str) { + let name = Name::new(queue_name).expect("Invalid queue name"); + let queue = Queue::open(name).expect("Could not open queue"); + + let message = Message { + data: content.as_bytes().to_vec(), + priority: 0, + }; + + match queue.send(&message) { + Ok(_) => (), + Err(e) => { + writeln!(io::stderr(), "Could not send message: {}", e).ok(); + exit(1); + } + } +} + fn main() { let ls = SubCommand::with_name("ls").about("list message queues"); @@ -105,6 +123,13 @@ fn main() { .about("Receive a message from a queue") .arg(&queue_arg); + let send = SubCommand::with_name("send") + .about("Send a message to a queue") + .arg(&queue_arg) + .arg(Arg::with_name("message") + .help("the message to send") + .required(true)); + let matches = App::new("mq") .setting(AppSettings::SubcommandRequiredElseHelp) @@ -114,13 +139,18 @@ fn main() { .subcommand(inspect) .subcommand(create) .subcommand(receive) + .subcommand(send) .get_matches(); match matches.subcommand() { ("ls", _) => run_ls(), ("inspect", Some(cmd)) => run_inspect(cmd.value_of("queue").unwrap()), - ("create", Some(cmd)) => run_create(cmd), + ("create", Some(cmd)) => run_create(cmd), ("receive", Some(cmd)) => run_receive(cmd.value_of("queue").unwrap()), + ("send", Some(cmd)) => run_send( + cmd.value_of("queue").unwrap(), + cmd.value_of("message").unwrap() + ), _ => unimplemented!(), } } -- cgit 1.4.1 From 2c71e092f69f5cd3c31ad8a84aa4168118579898 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Fri, 20 Oct 2017 21:40:25 +0200 Subject: refactor: Compatibility with Rust 1.20 for_each was stabilised in 1.21, but is not yet available in all distributions. --- src/main.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.rs b/src/main.rs index 634d98f900..7a80b97088 100644 --- a/src/main.rs +++ b/src/main.rs @@ -11,7 +11,7 @@ fn run_ls() { let mqueues = read_dir("/dev/mqueue") .expect("Could not read message queues"); - mqueues.for_each(|queue| { + for queue in mqueues { let path = queue.unwrap().path(); let status = { let mut file = File::open(&path) @@ -25,7 +25,7 @@ fn run_ls() { let queue_name = path.components().last().unwrap().as_os_str(); println!("{:?}: {}", queue_name, status) - }); + }; } fn run_inspect(queue_name: &str) { -- cgit 1.4.1 From d908fe1cbc7de0bff7cadbe0b3851d50229b7de2 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 13 Nov 2017 14:16:56 +0100 Subject: feat: Add commands to get/set message queue rlimit When creating a large number of queues the message queue rlimit may be reached (see mq_overview for details). This commit adds an `mq rlimit` function that displays the current rlimits and an optional `--rlimit` flag to the `create` command that can raise the rlimit when required. --- Cargo.lock | 2 ++ Cargo.toml | 4 +++- src/main.rs | 64 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 1 deletion(-) diff --git a/Cargo.lock b/Cargo.lock index 54a0009e24..24a652deb5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,6 +3,8 @@ name = "mq" version = "0.1.0" dependencies = [ "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "posix_mq 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] diff --git a/Cargo.toml b/Cargo.toml index 73d087f69b..7dd3896f93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,5 +4,7 @@ version = "0.1.0" authors = ["Vincent Ambo "] [dependencies] -posix_mq = "0.1.1" clap = "2.26.2" +libc = "0.2.32" +nix = "0.9.0" +posix_mq = "0.1.1" diff --git a/src/main.rs b/src/main.rs index 7a80b97088..e67798e9f3 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,7 @@ extern crate clap; extern crate posix_mq; +extern crate libc; +extern crate nix; use clap::{App, SubCommand, Arg, ArgMatches, AppSettings}; use posix_mq::{Name, Queue, Message}; @@ -38,6 +40,10 @@ fn run_inspect(queue_name: &str) { } fn run_create(cmd: &ArgMatches) { + if let Some(rlimit) = cmd.value_of("rlimit") { + set_rlimit(rlimit.parse().expect("Invalid rlimit value")); + } + let name = Name::new(cmd.value_of("queue").unwrap()) .expect("Invalid queue name"); @@ -96,11 +102,63 @@ fn run_send(queue_name: &str, content: &str) { } } +fn run_rlimit() { + let mut rlimit = libc::rlimit { + rlim_cur: 0, + rlim_max: 0, + }; + + let mut errno = 0; + unsafe { + let res = libc::getrlimit(libc::RLIMIT_MSGQUEUE, &mut rlimit); + if res != 0 { + errno = nix::errno::errno(); + } + }; + + if errno != 0 { + writeln!(io::stderr(), "Could not get message queue rlimit: {}", errno).ok(); + } else { + println!("Message queue rlimit:"); + println!("Current limit: {}", rlimit.rlim_cur); + println!("Maximum limit: {}", rlimit.rlim_max); + } +} + +fn set_rlimit(new_limit: u64) { + let rlimit = libc::rlimit { + rlim_cur: new_limit, + rlim_max: new_limit, + }; + + let mut errno: i32 = 0; + unsafe { + let res = libc::setrlimit(libc::RLIMIT_MSGQUEUE, &rlimit); + if res != 0 { + errno = nix::errno::errno(); + } + } + + match errno { + 0 => println!("Set RLIMIT_MSGQUEUE hard limit to {}", new_limit), + _ => { + // Not mapping these error codes to messages for now, the user can + // look up the meaning in setrlimit(2). + panic!("Could not set hard limit: {}", errno); + } + }; +} + fn main() { let ls = SubCommand::with_name("ls").about("list message queues"); let queue_arg = Arg::with_name("queue").required(true).takes_value(true); + let rlimit_arg = Arg::with_name("rlimit") + .help("RLIMIT_MSGQUEUE to set for this command") + .long("rlimit") + .takes_value(true); + let inspect = SubCommand::with_name("inspect") .about("inspect details about a queue") .arg(&queue_arg); @@ -108,6 +166,7 @@ fn main() { let create = SubCommand::with_name("create") .about("Create a new queue") .arg(&queue_arg) + .arg(&rlimit_arg) .arg(Arg::with_name("max-size") .help("maximum message size (in kB)") .long("max-size") @@ -130,6 +189,9 @@ fn main() { .help("the message to send") .required(true)); + let rlimit = SubCommand::with_name("rlimit") + .about("Get the message queue rlimit") + .setting(AppSettings::SubcommandRequiredElseHelp); let matches = App::new("mq") .setting(AppSettings::SubcommandRequiredElseHelp) @@ -140,6 +202,7 @@ fn main() { .subcommand(create) .subcommand(receive) .subcommand(send) + .subcommand(rlimit) .get_matches(); match matches.subcommand() { @@ -151,6 +214,7 @@ fn main() { cmd.value_of("queue").unwrap(), cmd.value_of("message").unwrap() ), + ("rlimit", _) => run_rlimit(), _ => unimplemented!(), } } -- cgit 1.4.1 From cfbfe1a3559bde98d13902785712c6c3384877cb Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 19 Mar 2018 14:07:51 +0100 Subject: chore(cargo): Bump dependency versions --- Cargo.lock | 165 +++++++++++++++++++++++++++++++++++++++---------------------- Cargo.toml | 12 ++--- 2 files changed, 112 insertions(+), 65 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 24a652deb5..059e3ec6c4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,27 +1,19 @@ -[root] -name = "mq" -version = "0.1.0" -dependencies = [ - "clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "posix_mq 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ansi_term" -version = "0.9.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "atty" -version = "0.2.3" +version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -29,6 +21,25 @@ name = "bitflags" version = "0.9.1" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "bitflags" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "byteorder" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "bytes" +version = "0.4.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", + "iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "cfg-if" version = "0.1.2" @@ -36,33 +47,47 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.26.2" +version = "2.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", - "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", - "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", + "ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "kernel32-sys" -version = "0.2.2" +name = "gcc" +version = "0.3.54" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "iovec" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "libc" -version = "0.2.32" +version = "0.2.39" source = "registry+https://github.com/rust-lang/crates.io-index" +[[package]] +name = "mq" +version = "1.0.0" +dependencies = [ + "clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)", + "posix_mq 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + [[package]] name = "nix" version = "0.9.0" @@ -70,22 +95,35 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "nix" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", + "gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "posix_mq" -version = "0.1.1" +version = "0.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", "nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "redox_syscall" -version = "0.1.31" +version = "0.1.37" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -93,40 +131,29 @@ name = "redox_termios" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "strsim" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "term_size" -version = "0.3.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", -] [[package]] name = "termion" version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)", - "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "textwrap" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -151,28 +178,48 @@ version = "0.2.8" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] -name = "winapi-build" -version = "0.1.1" +name = "winapi" +version = "0.3.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", + "winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] -"checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" -"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" +"checksum ansi_term 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" +"checksum atty 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "af80143d6f7608d746df1520709e5d141c96f240b0e62b0aa41bdfb53374d9d4" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" +"checksum bitflags 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "b3c30d3802dfb7281680d6285f2ccdaa8c2d8fee41f93805dba5c4cf50dc23cf" +"checksum byteorder 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "652805b7e73fada9d85e9a6682a4abd490cb52d96aeecc12e33a0de34dfd0d23" +"checksum bytes 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "1b7db437d718977f6dc9b2e3fd6fc343c02ac6b899b73fdd2179163447bd9ce9" "checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" -"checksum clap 2.26.2 (registry+https://github.com/rust-lang/crates.io-index)" = "3451e409013178663435d6f15fdb212f14ee4424a3d74f979d081d0a66b6f1f2" -"checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.32 (registry+https://github.com/rust-lang/crates.io-index)" = "56cce3130fd040c28df6f495c8492e5ec5808fb4c9093c310df02b0c8f030148" +"checksum clap 2.31.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5dc18f6f4005132120d9711636b32c46a233fad94df6217fa1d81c5e97a9f200" +"checksum gcc 0.3.54 (registry+https://github.com/rust-lang/crates.io-index)" = "5e33ec290da0d127825013597dbdfc28bee4964690c7ce1166cbc2a7bd08b1bb" +"checksum iovec 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "dbe6e417e7d0975db6512b90796e8ce223145ac4e33c377e4a42882a0e88bb08" +"checksum libc 0.2.39 (registry+https://github.com/rust-lang/crates.io-index)" = "f54263ad99207254cf58b5f701ecb432c717445ea2ee8af387334bdd1a03fdff" +"checksum nix 0.10.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b7fd5681d13fda646462cfbd4e5f2051279a89a544d50eb98c365b507246839f" "checksum nix 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a2c5afeb0198ec7be8569d666644b574345aad2e95a53baf3a532da3e0f3fb32" -"checksum posix_mq 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2ab51dbacda5aa610638256f89eb913747cc4156113f0a4df8619ae05d7549f5" -"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum posix_mq 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9a4e85a6efabe224decbdf47ff9e9d56cd44c91470734ffddb28351351f03f" +"checksum redox_syscall 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)" = "0d92eecebad22b767915e4d529f89f28ee96dbbf5a4810d2b844373f136417fd" "checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" -"checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" -"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" +"checksum strsim 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "bb4f380125926a99e52bc279241539c018323fab05ad6368b56f93d9369ff550" "checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" -"checksum textwrap 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "df8e08afc40ae3459e4838f303e465aa50d823df8d7f83ca88108f6d3afe7edd" +"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)" = "6a02e4885ed3bc0f2de90ea6dd45ebcbb66dacffe03547fadbb0eeae2770887d" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" -"checksum winapi-build 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" +"checksum winapi 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)" = "04e3bd221fcbe8a271359c04f21a76db7d0c6028862d1bb5512d85e1e2eb5bb3" +"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" +"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" diff --git a/Cargo.toml b/Cargo.toml index 7dd3896f93..609377793f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,10 +1,10 @@ [package] name = "mq" -version = "0.1.0" -authors = ["Vincent Ambo "] +version = "1.0.0" +authors = ["Vincent Ambo "] [dependencies] -clap = "2.26.2" -libc = "0.2.32" -nix = "0.9.0" -posix_mq = "0.1.1" +clap = "2.31" +libc = "0.2" +nix = "0.10" +posix_mq = "0.1.2" -- cgit 1.4.1 From ade52d2423a4f9f8e0190b4e438823cbbc910c75 Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 19 Mar 2018 14:08:05 +0100 Subject: fix(main): Fix formatting of queue name in ls-output --- src/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index e67798e9f3..55ff006429 100644 --- a/src/main.rs +++ b/src/main.rs @@ -25,8 +25,11 @@ fn run_ls() { content }; - let queue_name = path.components().last().unwrap().as_os_str(); - println!("{:?}: {}", queue_name, status) + let queue_name = path.components().last().unwrap() + .as_os_str() + .to_string_lossy(); + + println!("/{}: {}", queue_name, status) }; } @@ -195,7 +198,7 @@ fn main() { let matches = App::new("mq") .setting(AppSettings::SubcommandRequiredElseHelp) - .version("0.0.1") + .version("1.0.0") .about("Administrate and inspect POSIX message queues") .subcommand(ls) .subcommand(inspect) -- cgit 1.4.1 From df29b08bffc90cfd4f2d963a8e48d89f7a86308d Mon Sep 17 00:00:00 2001 From: Vincent Ambo Date: Mon, 19 Mar 2018 14:10:48 +0100 Subject: docs(README): Add simple README to project --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000000..e612553e74 --- /dev/null +++ b/README.md @@ -0,0 +1,31 @@ +mq-cli +====== + +This project provides a very simple CLI interface to [POSIX message queues][]. + +It can be used to create and inspect queues, as well as send and +receive messages from them. + +``` +1.0.0 +Administrate and inspect POSIX message queues + +USAGE: + mq + +FLAGS: + -h, --help Prints help information + -V, --version Prints version information + +SUBCOMMANDS: + create Create a new queue + help Prints this message or the help of the given subcommand(s) + inspect inspect details about a queue + ls list message queues + receive Receive a message from a queue + rlimit Get the message queue rlimit + send Send a message to a queue +``` + + +[POSIX message queues]: https://linux.die.net/man/7/mq_overview -- cgit 1.4.1