diff --git a/src/handshake.rs b/src/handshake.rs new file mode 100644 index 0000000..c293387 --- /dev/null +++ b/src/handshake.rs @@ -0,0 +1,23 @@ +pub const CONFIG_END: &str = "config|ready"; +pub const CONFIG_TAG: &str = "config|"; + +pub fn read_config() { + let mut buffer = String::new(); + let stdin = std::io::stdin(); + loop { + buffer.clear(); + stdin.read_line(&mut buffer).unwrap(); + let entry = buffer.trim_end(); + if entry == CONFIG_END { + return; + } + if !entry.starts_with(CONFIG_TAG) { + eprintln!("invalid config line: {entry}"); + } + } +} + +pub fn register_filter() { + println!("register|filter|smtp-in|data-line"); + println!("register|ready"); +} diff --git a/src/main.rs b/src/main.rs index e7a11a9..b0e76f1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,3 +1,6 @@ +mod handshake; + fn main() { - println!("Hello, world!"); + handshake::read_config(); + handshake::register_filter(); }