rust/hedgewars-checker/src/main.rs
changeset 14212 bb2f301d4fe0
parent 13962 a4877a16564d
child 14401 694c96fb3a06
equal deleted inserted replaced
14211:257b296169a8 14212:bb2f301d4fe0
     1 #[macro_use]
       
     2 extern crate log;
       
     3 extern crate argparse;
       
     4 extern crate base64;
       
     5 extern crate dirs;
       
     6 extern crate ini;
       
     7 extern crate netbuf;
       
     8 extern crate stderrlog;
       
     9 extern crate tempfile;
       
    10 
       
    11 use argparse::{ArgumentParser, Store};
     1 use argparse::{ArgumentParser, Store};
    12 use ini::Ini;
     2 use ini::Ini;
    13 use netbuf::Buf;
     3 use netbuf::Buf;
    14 use std::io::Write;
     4 use log::{debug, warn, info};
    15 use std::net::TcpStream;
     5 use std::{
    16 use std::process::Command;
     6     io::Write,
    17 use std::str::FromStr;
     7     net::TcpStream,
       
     8     process::Command,
       
     9     str::FromStr
       
    10 };
    18 
    11 
    19 type CheckError = Box<std::error::Error>;
    12 type CheckError = Box<std::error::Error>;
    20 
    13 
    21 fn extract_packet(buf: &mut Buf) -> Option<netbuf::Buf> {
    14 fn extract_packet(buf: &mut Buf) -> Option<netbuf::Buf> {
    22     let packet_end = (&buf[..]).windows(2).position(|window| window == b"\n\n")?;
    15     let packet_end = (&buf[..]).windows(2).position(|window| window == b"\n\n")?;
   217 
   210 
   218     let protocol_number = get_protocol_number(&exe.as_str()).unwrap_or_default();
   211     let protocol_number = get_protocol_number(&exe.as_str()).unwrap_or_default();
   219 
   212 
   220     info!("Using protocol number {}", protocol_number);
   213     info!("Using protocol number {}", protocol_number);
   221 
   214 
   222     connect_and_run(&username, &password, protocol_number, &exe, &prefix);
   215     connect_and_run(&username, &password, protocol_number, &exe, &prefix).unwrap();
   223 }
   216 }
   224 
   217 
   225 #[cfg(test)]
   218 #[cfg(test)]
   226 #[test]
   219 #[test]
   227 fn test() {
   220 fn test() {