move to native

master
Avril 5 years ago
parent 4f9c26ba3c
commit a50d4a1cc8
Signed by: flanchan
GPG Key ID: 284488987C31F630

1
.gitignore vendored

@ -5,3 +5,4 @@ obj/
sha256_literal/ sha256_literal/
**/target/ **/target/
test.txt test.txt
file.h

@ -0,0 +1,3 @@
sfexec-output:
g++ -Iinclude/ -w --std=c++17 main.cpp sha256_literal/sha256.cpp -o sfexec

@ -1,13 +0,0 @@
constexpr const int DATA_COUNT = 1;
constexpr const char* const DATA_EXEC_AFTER = nullptr;
static constexpr auto DATA_EXEC_AFTER_HASH = "unbound"_sha256;
constexpr const unsigned char DATA[] = {
0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x20, 0x70, 0x6c,
0x61, 0x6e, 0x65, 0x74, 0x21, 0x0a,
};
constexpr const long DATA_LENGTHS[DATA_COUNT] = {
14ll,
};
constexpr const char* const DATA_NAMES[DATA_COUNT] = {
"test.txt",
};

@ -22,6 +22,12 @@ mod arg;
use opt::Opt; use opt::Opt;
macro_rules! flush {
() => {
std::io::stdout().flush().ok().expect("fatal: could not flush stdout")
}
}
fn usage() -> ! { fn usage() -> ! {
let prog = &arg::program_name(); let prog = &arg::program_name();
println!("Usage: {} [-s] [-e <exec string>] [-o <output file>] [-] <files...>", prog); println!("Usage: {} [-s] [-e <exec string>] [-o <output file>] [-] <files...>", prog);
@ -115,8 +121,8 @@ fn main() -> Result<(), Box<dyn Error>>{
if let Some(exec) = exec { if let Some(exec) = exec {
let exec = translate::c_escape(exec); let exec = translate::c_escape(exec);
writeln!(fp, "constexpr const char* const DATA_EXEC_AFTER = {};", exec)?; writeln!(fp, "constexpr const char* const DATA_EXEC_AFTER = \"{}\";", exec)?;
writeln!(fp, "static constexpr auto DATA_EXEC_AFTER_HASH = {}_sha256;", exec)?; writeln!(fp, "static constexpr auto DATA_EXEC_AFTER_HASH = \"{}\"_sha256;", exec)?;
} else { } else {
writeln!(fp, "constexpr const char* const DATA_EXEC_AFTER = nullptr;")?; writeln!(fp, "constexpr const char* const DATA_EXEC_AFTER = nullptr;")?;
writeln!(fp, "static constexpr auto DATA_EXEC_AFTER_HASH = \"unbound\"_sha256;")?; writeln!(fp, "static constexpr auto DATA_EXEC_AFTER_HASH = \"unbound\"_sha256;")?;
@ -127,6 +133,7 @@ fn main() -> Result<(), Box<dyn Error>>{
for file in files.iter() { for file in files.iter() {
print!(" + {}", file); print!(" + {}", file);
flush!();
let file = OpenOptions::new() let file = OpenOptions::new()
.read(true) .read(true)
.open(file)?; .open(file)?;
@ -158,6 +165,7 @@ fn main() -> Result<(), Box<dyn Error>>{
for file in files.into_iter() { for file in files.into_iter() {
let file = Path::new(&file); let file = Path::new(&file);
print!(" - {:?}", file); print!(" - {:?}", file);
flush!();
let file = match attempt_get_name(&file) { let file = match attempt_get_name(&file) {
Ok(file) => file, Ok(file) => file,
Err(error) => { Err(error) => {

Loading…
Cancel
Save