Remove hacky macro module

This commit is contained in:
Steven Fackler 2013-11-26 18:12:12 -08:00
parent 1bd57d7ffb
commit 3a2800a2fa
1 changed files with 16 additions and 21 deletions

19
lib.rs
View File

@ -16,7 +16,6 @@ use std::io::{Stream, Reader, Writer, Decorator};
use std::vec; use std::vec;
use self::error::{SslError, SslSessionClosed, StreamEof}; use self::error::{SslError, SslSessionClosed, StreamEof};
use self::hack::X509ValidationError;
pub mod error; pub mod error;
@ -165,11 +164,11 @@ impl SslContext {
/// Specifies the file that contains trusted CA certificates. /// Specifies the file that contains trusted CA certificates.
pub fn set_CA_file(&mut self, file: &str) -> Option<SslError> { pub fn set_CA_file(&mut self, file: &str) -> Option<SslError> {
let ret = do file.with_c_str |file| { let ret = file.with_c_str(|file| {
unsafe { unsafe {
ffi::SSL_CTX_load_verify_locations(self.ctx, file, ptr::null()) ffi::SSL_CTX_load_verify_locations(self.ctx, file, ptr::null())
} }
}; });
if ret == 0 { if ret == 0 {
Some(SslError::get()) Some(SslError::get())
@ -217,9 +216,6 @@ pub enum X509NameFormat {
macro_rules! make_validation_error( macro_rules! make_validation_error(
($ok_val:ident, $($name:ident = $val:ident,)+) => ( ($ok_val:ident, $($name:ident = $val:ident,)+) => (
pub mod hack {
use std::libc::c_int;
pub enum X509ValidationError { pub enum X509ValidationError {
$($name,)+ $($name,)+
X509UnknownError(c_int) X509UnknownError(c_int)
@ -229,13 +225,12 @@ macro_rules! make_validation_error(
#[doc(hidden)] #[doc(hidden)]
pub fn from_raw(err: c_int) -> Option<X509ValidationError> { pub fn from_raw(err: c_int) -> Option<X509ValidationError> {
match err { match err {
super::ffi::$ok_val => None, self::ffi::$ok_val => None,
$(super::ffi::$val => Some($name),)+ $(self::ffi::$val => Some($name),)+
err => Some(X509UnknownError(err)) err => Some(X509UnknownError(err))
} }
} }
} }
}
) )
) )
@ -459,7 +454,7 @@ impl<S: Stream> SslStream<S> {
} }
} }
fn in_retry_wrapper(&mut self, blk: &fn(&Ssl) -> c_int) fn in_retry_wrapper(&mut self, blk: |&Ssl| -> c_int)
-> Result<c_int, SslError> { -> Result<c_int, SslError> {
loop { loop {
let ret = blk(&self.ssl); let ret = blk(&self.ssl);
@ -512,9 +507,9 @@ impl<S: Stream> Writer for SslStream<S> {
fn write(&mut self, buf: &[u8]) { fn write(&mut self, buf: &[u8]) {
let mut start = 0; let mut start = 0;
while start < buf.len() { while start < buf.len() {
let ret = do self.in_retry_wrapper |ssl| { let ret = self.in_retry_wrapper(|ssl| {
ssl.write(buf.slice_from(start)) ssl.write(buf.slice_from(start))
}; });
match ret { match ret {
Ok(len) => start += len as uint, Ok(len) => start += len as uint,
_ => unreachable!() _ => unreachable!()