Move db to crate root
This commit is contained in:
@@ -1,31 +0,0 @@
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use c_str::CStr;
|
||||
use fs::File;
|
||||
use header::fcntl;
|
||||
use io::{self, BufRead, BufReader};
|
||||
|
||||
pub struct Db(BufReader<File>);
|
||||
|
||||
impl Db {
|
||||
pub fn new(path: &CStr) -> io::Result<Self> {
|
||||
File::open(path, fcntl::O_RDONLY)
|
||||
.map(BufReader::new)
|
||||
.map(Db)
|
||||
}
|
||||
|
||||
pub fn read(&mut self) -> io::Result<Vec<String>> {
|
||||
let mut parts = Vec::new();
|
||||
|
||||
let mut line = String::new();
|
||||
self.0.read_line(&mut line)?;
|
||||
if let Some(not_comment) = line.split('#').next() {
|
||||
for part in not_comment.split_whitespace() {
|
||||
parts.push(part.to_string());
|
||||
}
|
||||
}
|
||||
|
||||
Ok(parts)
|
||||
}
|
||||
}
|
||||
@@ -10,12 +10,6 @@ use alloc::str::SplitWhitespace;
|
||||
use alloc::vec::Vec;
|
||||
|
||||
use c_str::{CStr, CString};
|
||||
|
||||
use platform;
|
||||
use platform::rlb::{Line, RawLineBuffer};
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
use header::arpa_inet::{htons, inet_aton};
|
||||
use header::errno::*;
|
||||
use header::fcntl::O_RDONLY;
|
||||
@@ -25,6 +19,10 @@ use header::strings::strcasecmp;
|
||||
use header::sys_socket::constants::AF_INET;
|
||||
use header::sys_socket::{sockaddr, socklen_t};
|
||||
use header::unistd::SEEK_SET;
|
||||
use platform;
|
||||
use platform::rlb::{Line, RawLineBuffer};
|
||||
use platform::types::*;
|
||||
use platform::{Pal, Sys};
|
||||
|
||||
#[cfg(target_os = "linux")]
|
||||
#[path = "linux.rs"]
|
||||
@@ -34,9 +32,6 @@ pub mod sys;
|
||||
#[path = "redox.rs"]
|
||||
pub mod sys;
|
||||
|
||||
//TODO: use self::db::Db;
|
||||
pub mod db;
|
||||
|
||||
use self::lookup::{lookup_addr, lookup_host};
|
||||
pub mod lookup;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user