diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Cargo.toml | 22 | ||||
-rw-r--r-- | buffered-reader/Cargo.toml | 8 | ||||
-rw-r--r-- | buffered-reader/src/buffered-reader-test.txt (renamed from src/buffered_reader/buffered-reader-test.txt) | 0 | ||||
-rw-r--r-- | buffered-reader/src/decompress.rs (renamed from src/buffered_reader/decompress.rs) | 0 | ||||
-rw-r--r-- | buffered-reader/src/generic.rs (renamed from src/buffered_reader/generic.rs) | 2 | ||||
-rw-r--r-- | buffered-reader/src/lib.rs (renamed from src/buffered_reader/buffered_reader.rs) | 12 | ||||
-rw-r--r-- | buffered-reader/src/limitor.rs (renamed from src/buffered_reader/limitor.rs) | 0 | ||||
-rw-r--r-- | buffered-reader/src/memory.rs (renamed from src/buffered_reader/memory.rs) | 0 | ||||
-rw-r--r-- | buffered-reader/src/mod.rs (renamed from src/buffered_reader/mod.rs) | 0 | ||||
-rw-r--r-- | core/Cargo.toml | 6 | ||||
-rw-r--r-- | core/src/lib.rs | 103 | ||||
-rw-r--r-- | ffi/Cargo.toml | 16 | ||||
-rw-r--r-- | ffi/src/lib.rs (renamed from src/ffi.rs) | 36 | ||||
-rw-r--r-- | ffi/src/sequoia.h (renamed from src/sequoia.h) | 0 | ||||
-rw-r--r-- | net/Cargo.toml | 18 | ||||
-rw-r--r-- | net/src/lib.rs (renamed from src/net/mod.rs) | 29 | ||||
-rw-r--r-- | net/src/sks-keyservers.netCA.der (renamed from src/net/sks-keyservers.netCA.der) | bin | 1423 -> 1423 bytes | |||
-rw-r--r-- | openpgp/Cargo.toml | 11 | ||||
-rw-r--r-- | openpgp/src/armor.rs (renamed from src/openpgp/armor.rs) | 2 | ||||
-rw-r--r-- | openpgp/src/build/build.rs (renamed from src/openpgp/build/build.rs) | 0 | ||||
-rw-r--r-- | openpgp/src/build/mod.rs (renamed from src/openpgp/build/mod.rs) | 0 | ||||
-rw-r--r-- | openpgp/src/lib.rs (renamed from src/openpgp/openpgp.rs) | 20 | ||||
-rw-r--r-- | openpgp/src/packets.rs (renamed from tests/data/armor/test-0.bin) | 0 | ||||
-rw-r--r-- | openpgp/src/parse/compressed-data-algo-1.asc (renamed from src/openpgp/parse/compressed-data-algo-1.asc) | bin | 2282 -> 2282 bytes | |||
-rw-r--r-- | openpgp/src/parse/compressed-data-algo-2.asc (renamed from src/openpgp/parse/compressed-data-algo-2.asc) | bin | 2288 -> 2288 bytes | |||
-rw-r--r-- | openpgp/src/parse/compressed-data-algo-3.asc (renamed from src/openpgp/parse/compressed-data-algo-3.asc) | bin | 2216 -> 2216 bytes | |||
-rw-r--r-- | openpgp/src/parse/compression-quine.gpg (renamed from src/openpgp/parse/compression-quine.gpg) | bin | 182 -> 182 bytes | |||
-rw-r--r-- | openpgp/src/parse/compression-quine.txt (renamed from src/openpgp/parse/compression-quine.txt) | 0 | ||||
-rw-r--r-- | openpgp/src/parse/literal-mode-b.asc (renamed from src/openpgp/parse/literal-mode-b.asc) | 0 | ||||
-rw-r--r-- | openpgp/src/parse/literal-mode-t-partial-body.asc (renamed from src/openpgp/parse/literal-mode-t-partial-body.asc) | 0 | ||||
-rw-r--r-- | openpgp/src/parse/literal-mode-t-partial-body.txt (renamed from src/openpgp/parse/literal-mode-t-partial-body.txt) | 0 | ||||
-rw-r--r-- | openpgp/src/parse/mod.rs (renamed from src/openpgp/parse/mod.rs) | 1 | ||||
-rw-r--r-- | openpgp/src/parse/parse.rs (renamed from src/openpgp/parse/parse.rs) | 3 | ||||
-rw-r--r-- | openpgp/src/parse/public-key.asc (renamed from src/openpgp/parse/public-key.asc) | bin | 25148 -> 25148 bytes | |||
-rw-r--r-- | openpgp/src/parse/sig.asc (renamed from src/openpgp/parse/sig.asc) | bin | 310 -> 310 bytes | |||
-rw-r--r-- | openpgp/src/parse/signed.gpg (renamed from src/openpgp/parse/signed.gpg) | bin | 456 -> 456 bytes | |||
-rw-r--r-- | openpgp/src/partial_body.rs (renamed from src/buffered_reader/partial_body.rs) | 8 | ||||
-rw-r--r-- | openpgp/src/serialize/mod.rs (renamed from src/openpgp/serialize/mod.rs) | 0 | ||||
-rw-r--r-- | openpgp/src/serialize/serialize.rs (renamed from src/openpgp/serialize/serialize.rs) | 0 | ||||
-rw-r--r-- | openpgp/src/subpackets.rs (renamed from src/openpgp/subpackets.rs) | 3 | ||||
-rw-r--r-- | openpgp/src/tpk.rs (renamed from src/openpgp/tpk.rs) | 51 | ||||
-rw-r--r-- | openpgp/src/types.rs (renamed from src/openpgp/types.rs) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-0.asc (renamed from tests/data/armor/test-0.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-0.bad-crc.asc (renamed from tests/data/armor/test-0.bad-crc.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-0.bin | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-1.asc (renamed from tests/data/armor/test-1.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-1.bin (renamed from tests/data/armor/test-1.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-1.no-crc.asc (renamed from tests/data/armor/test-1.no-crc.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-2.asc (renamed from tests/data/armor/test-2.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-2.bad-footer.asc (renamed from tests/data/armor/test-2.bad-footer.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-2.bin (renamed from tests/data/armor/test-2.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-3.asc (renamed from tests/data/armor/test-3.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-3.bin (renamed from tests/data/armor/test-3.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-3.with-headers.asc (renamed from tests/data/armor/test-3.with-headers.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-47.asc (renamed from tests/data/armor/test-47.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-47.bin (renamed from tests/data/armor/test-47.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-48.asc (renamed from tests/data/armor/test-48.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-48.bin (renamed from tests/data/armor/test-48.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-49.asc (renamed from tests/data/armor/test-49.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-49.bin (renamed from tests/data/armor/test-49.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-50.asc (renamed from tests/data/armor/test-50.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-50.bin (renamed from tests/data/armor/test-50.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-51.asc (renamed from tests/data/armor/test-51.asc) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/armor/test-51.bin (renamed from tests/data/armor/test-51.bin) | 0 | ||||
-rw-r--r-- | openpgp/tests/data/keys/testy-broken-no-pk.pgp (renamed from tests/data/keys/testy-broken-no-pk.pgp) | bin | 966 -> 966 bytes | |||
-rw-r--r-- | openpgp/tests/data/keys/testy-broken-no-sig-on-subkey.pgp (renamed from tests/data/keys/testy-broken-no-sig-on-subkey.pgp) | bin | 925 -> 925 bytes | |||
-rw-r--r-- | openpgp/tests/data/keys/testy-broken-no-uid.pgp (renamed from tests/data/keys/testy-broken-no-uid.pgp) | bin | 857 -> 857 bytes | |||
-rw-r--r-- | openpgp/tests/data/keys/testy-no-subkey.pgp (renamed from tests/data/keys/testy-no-subkey.pgp) | bin | 653 -> 653 bytes | |||
-rw-r--r-- | openpgp/tests/data/keys/testy.pgp (renamed from tests/data/keys/testy.pgp) | bin | 1238 -> 1238 bytes | |||
-rw-r--r-- | src/lib.rs | 127 | ||||
-rw-r--r-- | src/openpgp/mod.rs | 11 | ||||
-rw-r--r-- | store/Cargo.toml | 6 | ||||
-rw-r--r-- | store/src/lib.rs (renamed from src/store/mod.rs) | 0 |
74 files changed, 297 insertions, 199 deletions
@@ -2,5 +2,4 @@ **/*.rs.bk *~ Cargo.lock -core .gdb_history @@ -3,25 +3,19 @@ name = "sequoia" version = "0.1.0" authors = ["Neal H. Walfield <neal@gnu.org>"] +[workspace] + [dependencies] -base64 = "0.8.0" -bzip2 = "0.3.2" -flate2 = "0.2" -futures = "0.1" -hyper = "0.11" -hyper-tls = "0.1.2" -libc = "0.2.33" -native-tls = "0.1.4" -nom = "3.2.0" -num = "0.1.40" -num-derive = "0.1.41" -percent-encoding = "1.0.1" -tokio-core = "0.1" +buffered-reader = { path = "buffered-reader" } +openpgp = { path = "openpgp" } +sequoia-core = { path = "core" } +sequoia-ffi = { path = "ffi" } +sequoia-net = { path = "net" } +sequoia-store = { path = "store" } [lib] name = "sequoia" path = "src/lib.rs" -crate-type = ["lib", "dylib"] [[bin]] doc = false diff --git a/buffered-reader/Cargo.toml b/buffered-reader/Cargo.toml new file mode 100644 index 00000000..c7677bab --- /dev/null +++ b/buffered-reader/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "buffered-reader" +version = "0.1.0" +authors = ["Neal H. Walfield <neal@gnu.org>"] + +[dependencies] +bzip2 = "0.3.2" +flate2 = "0.2" diff --git a/src/buffered_reader/buffered-reader-test.txt b/buffered-reader/src/buffered-reader-test.txt index 77dbaaa8..77dbaaa8 100644 --- a/src/buffered_reader/buffered-reader-test.txt +++ b/buffered-reader/src/buffered-reader-test.txt diff --git a/src/buffered_reader/decompress.rs b/buffered-reader/src/decompress.rs index 648037fc..648037fc 100644 --- a/src/buffered_reader/decompress.rs +++ b/buffered-reader/src/decompress.rs diff --git a/src/buffered_reader/generic.rs b/buffered-reader/src/generic.rs index 7049a2fe..92ed6151 100644 --- a/src/buffered_reader/generic.rs +++ b/buffered-reader/src/generic.rs @@ -232,7 +232,7 @@ fn buffered_reader_generic_test() { use std::fs::File; let path : PathBuf = [env!("CARGO_MANIFEST_DIR"), - "src", "buffered_reader", "buffered-reader-test.txt"] + "src", "buffered-reader-test.txt"] .iter().collect(); let mut f = File::open(&path).expect(&path.to_string_lossy()); let mut bio = BufferedReaderGeneric::new(&mut f, None); diff --git a/src/buffered_reader/buffered_reader.rs b/buffered-reader/src/lib.rs index ebcb4dc9..951b8c71 100644 --- a/src/buffered_reader/buffered_reader.rs +++ b/buffered-reader/src/lib.rs @@ -1,4 +1,8 @@ -use std; +//! An improved `BufRead` interface. + +extern crate flate2; +extern crate bzip2; + use std::str; use std::io; use std::io::{Error,ErrorKind}; @@ -8,13 +12,11 @@ use std::fmt; mod generic; mod memory; mod limitor; -mod partial_body; mod decompress; pub use self::generic::BufferedReaderGeneric; pub use self::memory::BufferedReaderMemory; pub use self::limitor::BufferedReaderLimitor; -pub use self::partial_body::BufferedReaderPartialBodyFilter; pub use self::decompress::BufferedReaderDeflate; pub use self::decompress::BufferedReaderZlib; pub use self::decompress::BufferedReaderBzip; @@ -177,7 +179,7 @@ pub trait BufferedReader : io::Read + fmt::Debug { /// /// but, alas, Rust doesn't like that ("error[E0119]: conflicting /// implementations of trait `std::io::Read` for type `&mut _`"). -fn buffered_reader_generic_read_impl<T: BufferedReader> +pub fn buffered_reader_generic_read_impl<T: BufferedReader> (bio: &mut T, buf: &mut [u8]) -> Result<usize, io::Error> { match bio.data_consume(buf.len()) { Ok(inner) => { @@ -358,7 +360,7 @@ mod test { use std::fs::File; let path : PathBuf = [env!("CARGO_MANIFEST_DIR"), - "src", "buffered_reader", + "src", "buffered-reader-test.txt"] .iter().collect(); diff --git a/src/buffered_reader/limitor.rs b/buffered-reader/src/limitor.rs index 052ceb0d..052ceb0d 100644 --- a/src/buffered_reader/limitor.rs +++ b/buffered-reader/src/limitor.rs diff --git a/src/buffered_reader/memory.rs b/buffered-reader/src/memory.rs index 327e4bcb..327e4bcb 100644 --- a/src/buffered_reader/memory.rs +++ b/buffered-reader/src/memory.rs diff --git a/src/buffered_reader/mod.rs b/buffered-reader/src/mod.rs index 856a295b..856a295b 100644 --- a/src/buffered_reader/mod.rs +++ b/buffered-reader/src/mod.rs diff --git a/core/Cargo.toml b/core/Cargo.toml new file mode 100644 index 00000000..034cc2fd --- /dev/null +++ b/core/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "sequoia-core" +version = "0.1.0" +authors = ["Justus Winter <justus@pep-project.org>"] + +[dependencies] diff --git a/core/src/lib.rs b/core/src/lib.rs new file mode 100644 index 00000000..efddaa0b --- /dev/null +++ b/core/src/lib.rs @@ -0,0 +1,103 @@ +//! Core functionality. + +use std::env; +use std::fs; +use std::io; +use std::path::{Path, PathBuf}; + +/// A `&Context` is required for many operations. +/// +/// # Example +/// +/// ``` +/// # use sequoia_core::Context; +/// let c = Context::new("org.example.webmail").unwrap(); +/// ``` +pub struct Context { + domain: String, + home: PathBuf, + lib: PathBuf, +} + +fn prefix() -> PathBuf { + /* XXX: Windows support. */ + PathBuf::from(option_env!("PREFIX").or(Some("/usr/local")).unwrap()) +} + +impl Context { + /// Creates a Context with reasonable defaults. + /// + /// `domain` should uniquely identify your application, it is + /// strongly suggested to use a reversed fully qualified domain + /// name that is associated with your application. + pub fn new(domain: &str) -> io::Result<Self> { + Self::configure(domain).build() + } + + /// Creates a Context that can be configured. + /// + /// `domain` should uniquely identify your application, it is + /// strongly suggested to use a reversed fully qualified domain + /// name that is associated with your application. + /// + /// The configuration is seeded like in `Context::new`, but can be + /// modified. A configuration has to be finalized using + /// `.build()` in order to turn it into a Context. + pub fn configure(domain: &str) -> Config { + Config(Context { + domain: String::from(domain), + home: env::home_dir().unwrap_or(env::temp_dir()) + .join(".sequoia"), + lib: prefix().join("lib").join("sequoia"), + }) + } + + /// Returns the domain of the context. + pub fn domain(&self) -> &str { + &self.domain + } + + /// Returns the directory containing shared state. + pub fn home(&self) -> &Path { + &self.home + } + + /// Returns the directory containing backend servers. + pub fn lib(&self) -> &Path { + &self.lib + } +} + +/// Represents a `Context` configuration. +pub struct Config(Context); + +impl Config { + /// Finalizes the configuration and return a `Context`. + pub fn build(self) -> io::Result<Context> { + let c |