|
|
|
@ -135,10 +135,10 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn download_file(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
mut file: &mut File,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
file: &mut File,
|
|
|
|
|
) -> bool {
|
|
|
|
|
if self.config.verbose {
|
|
|
|
|
eprintln!("downloading [{}]...", selector);
|
|
|
|
@ -165,9 +165,9 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn download_temp(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
) -> bool {
|
|
|
|
|
let mut tmpfile = match NamedTempFile::new() {
|
|
|
|
|
Ok(f) => f,
|
|
|
|
@ -186,11 +186,11 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn add_link(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut which: char,
|
|
|
|
|
mut name: String,
|
|
|
|
|
mut host: String,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: String,
|
|
|
|
|
which: char,
|
|
|
|
|
name: String,
|
|
|
|
|
host: String,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: String,
|
|
|
|
|
) {
|
|
|
|
|
let mut a: char = '\0';
|
|
|
|
|
let mut b: char = '\0';
|
|
|
|
@ -283,10 +283,10 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn view_directory(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
mut make_current: libc::c_int,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
make_current: bool,
|
|
|
|
|
) {
|
|
|
|
|
let stream = dial(&host, port, selector);
|
|
|
|
|
let mut buffer = String::new();
|
|
|
|
@ -297,7 +297,7 @@ impl BrowserState {
|
|
|
|
|
};
|
|
|
|
|
/* only adapt current prompt when successful */
|
|
|
|
|
/* make history entry */
|
|
|
|
|
if make_current != 0 {
|
|
|
|
|
if make_current {
|
|
|
|
|
self.add_history();
|
|
|
|
|
}
|
|
|
|
|
/* don't overwrite the current_* things... */
|
|
|
|
@ -331,10 +331,10 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn view_file(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut cmd: &str,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
cmd: &str,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
) {
|
|
|
|
|
if !self.download_temp(host, port, selector) {
|
|
|
|
|
return;
|
|
|
|
@ -362,9 +362,9 @@ impl BrowserState {
|
|
|
|
|
|
|
|
|
|
pub unsafe fn view_download(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
) {
|
|
|
|
|
let mut filename: String =
|
|
|
|
|
Path::new(selector).file_name().unwrap_or_default().to_string_lossy().into();
|
|
|
|
@ -390,16 +390,16 @@ impl BrowserState {
|
|
|
|
|
};
|
|
|
|
|
// O_CREAT, O_NOCTTY, O_WRONLY, O_EXCL
|
|
|
|
|
if !self.download_file(host, port, selector, &mut file) {
|
|
|
|
|
println!("error: eunable to download [{}]", selector);
|
|
|
|
|
println!("error: unable to download [{}]", selector);
|
|
|
|
|
fs::remove_file(filename).expect("failed to delete file");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub unsafe fn view_search(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut host: &str,
|
|
|
|
|
mut port: u16,
|
|
|
|
|
mut selector: &str,
|
|
|
|
|
host: &str,
|
|
|
|
|
port: u16,
|
|
|
|
|
selector: &str,
|
|
|
|
|
) {
|
|
|
|
|
let search_selector: String = match input("enter search string: ").as_str() {
|
|
|
|
|
"" => {
|
|
|
|
@ -408,10 +408,10 @@ impl BrowserState {
|
|
|
|
|
}
|
|
|
|
|
s => format!("{}\t{}", selector, s),
|
|
|
|
|
};
|
|
|
|
|
self.view_directory(host, port, &search_selector, 1 as libc::c_int);
|
|
|
|
|
self.view_directory(host, port, &search_selector, true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub unsafe fn view_history(&mut self, mut key: Option<usize>) {
|
|
|
|
|
pub unsafe fn view_history(&mut self, key: Option<usize>) {
|
|
|
|
|
let mut history_key: usize = 0;
|
|
|
|
|
let mut a: char = '\0';
|
|
|
|
|
let mut b: char = '\0';
|
|
|
|
@ -440,7 +440,7 @@ impl BrowserState {
|
|
|
|
|
&(*l).host,
|
|
|
|
|
(*l).port,
|
|
|
|
|
&(*l).selector,
|
|
|
|
|
0 as libc::c_int,
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
@ -471,7 +471,7 @@ impl BrowserState {
|
|
|
|
|
&self.parsed_host.clone(),
|
|
|
|
|
self.parsed_port.clone(),
|
|
|
|
|
&self.parsed_selector.clone(),
|
|
|
|
|
0 as libc::c_int,
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
println!("invalid gopher URI: {}", bookmark,);
|
|
|
|
@ -492,7 +492,7 @@ impl BrowserState {
|
|
|
|
|
&(*h).host,
|
|
|
|
|
(*h).port,
|
|
|
|
|
&(*h).selector,
|
|
|
|
|
0 as libc::c_int,
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
/* history is history... :) */
|
|
|
|
@ -522,7 +522,7 @@ impl BrowserState {
|
|
|
|
|
&(*l).host,
|
|
|
|
|
(*l).port,
|
|
|
|
|
&(*l).selector,
|
|
|
|
|
1 as libc::c_int,
|
|
|
|
|
true,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
'7' => {
|
|
|
|
@ -664,7 +664,7 @@ impl BrowserState {
|
|
|
|
|
&self.parsed_host.clone(),
|
|
|
|
|
self.parsed_port.clone(),
|
|
|
|
|
&self.parsed_selector.clone(),
|
|
|
|
|
0 as libc::c_int,
|
|
|
|
|
false,
|
|
|
|
|
); /* to display the prompt */
|
|
|
|
|
loop {
|
|
|
|
|
// todo color prompt
|
|
|
|
@ -685,7 +685,7 @@ impl BrowserState {
|
|
|
|
|
&self.current_host.clone(),
|
|
|
|
|
self.current_port,
|
|
|
|
|
&self.current_selector.clone(),
|
|
|
|
|
0 as libc::c_int,
|
|
|
|
|
false,
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
Some('.') => {
|
|
|
|
@ -711,7 +711,7 @@ impl BrowserState {
|
|
|
|
|
&self.parsed_host.clone(),
|
|
|
|
|
self.parsed_port.clone(),
|
|
|
|
|
&self.parsed_selector.clone(),
|
|
|
|
|
1 as libc::c_int,
|
|
|
|
|
true,
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
println!("invalid gopher URI");
|
|
|
|
|