@@ -347,112 +347,7 @@ pub fn test_ipv6_literal_1() {
347347 }
348348 } ;
349349}
350- pub fn test_family_mismatch_2 ( ) {
351- let hints: Value < libcc2rs:: Addrinfo > = Rc :: new ( RefCell :: new ( Default :: default ( ) ) ) ;
352- ( * ( * hints. borrow ( ) ) . ai_flags . borrow_mut ( ) ) = 0 ;
353- ( * ( * hints. borrow ( ) ) . ai_protocol . borrow_mut ( ) ) = 0 ;
354- ( * ( * hints. borrow ( ) ) . ai_addrlen . borrow_mut ( ) ) = 0_u32 ;
355- ( * ( * hints. borrow ( ) ) . ai_addr . borrow_mut ( ) ) = Ptr :: < libcc2rs:: Sockaddr > :: null ( ) ;
356- ( * ( * hints. borrow ( ) ) . ai_canonname . borrow_mut ( ) ) = Ptr :: < u8 > :: null ( ) ;
357- ( * ( * hints. borrow ( ) ) . ai_next . borrow_mut ( ) ) = Ptr :: < libcc2rs:: Addrinfo > :: null ( ) ;
358- ( * ( * hints. borrow ( ) ) . ai_family . borrow_mut ( ) ) = libc:: AF_INET6 ;
359- ( * ( * hints. borrow ( ) ) . ai_socktype . borrow_mut ( ) ) = libc:: SOCK_STREAM ;
360- let res: Value < Ptr < libcc2rs:: Addrinfo > > =
361- Rc :: new ( RefCell :: new ( Ptr :: < libcc2rs:: Addrinfo > :: null ( ) ) ) ;
362- assert ! (
363- ( ( ( {
364- let __node = Ptr :: from_string_literal( b"127.0.0.1" ) . clone( ) ;
365- let __service = Ptr :: from_string_literal( b"80" ) . clone( ) ;
366- let __hints = ( hints. as_pointer( ) ) . clone( ) ;
367- let __out = ( res. as_pointer( ) ) . clone( ) ;
368- let __family = if __hints. is_null( ) {
369- :: libc:: AF_UNSPEC
370- } else {
371- __hints. with( |__h| * __h. ai_family. borrow( ) )
372- } ;
373- let __socktype = if __hints. is_null( ) {
374- 0
375- } else {
376- __hints. with( |__h| * __h. ai_socktype. borrow( ) )
377- } ;
378- let __protocol = if __hints. is_null( ) {
379- 0
380- } else {
381- __hints. with( |__h| * __h. ai_protocol. borrow( ) )
382- } ;
383- let __port: u16 = if __service. is_null( ) {
384- 0
385- } else {
386- __service. to_rust_string( ) . parse( ) . unwrap_or( 0 )
387- } ;
388- let mut __addrs: Vec <:: std:: net:: IpAddr > = Vec :: new( ) ;
389- if __node. is_null( ) {
390- if __family == :: libc:: AF_INET6 {
391- __addrs. push( :: std:: net:: IpAddr :: V6 ( :: std:: net:: Ipv6Addr :: UNSPECIFIED ) ) ;
392- } else {
393- __addrs. push( :: std:: net:: IpAddr :: V4 ( :: std:: net:: Ipv4Addr :: UNSPECIFIED ) ) ;
394- }
395- } else {
396- let __host = __node. to_rust_string( ) ;
397- match __host. parse:: <:: std:: net:: IpAddr >( ) {
398- Ok ( __ip) => __addrs. push( __ip) ,
399- Err ( _) => {
400- use :: std:: net:: ToSocketAddrs ;
401- match ( __host. as_str( ) , __port) . to_socket_addrs( ) {
402- Ok ( __it) => {
403- for __sa in __it {
404- __addrs. push( __sa. ip( ) ) ;
405- }
406- }
407- Err ( _) => { }
408- }
409- }
410- }
411- }
412- __addrs. retain( |__ip| match __family {
413- :: libc:: AF_INET => __ip. is_ipv4( ) ,
414- :: libc:: AF_INET6 => __ip. is_ipv6( ) ,
415- _ => true ,
416- } ) ;
417- if __addrs. is_empty( ) {
418- :: libc:: EAI_NONAME
419- } else {
420- let mut __next = Ptr :: <Addrinfo >:: null( ) ;
421- for __ip in __addrs. iter( ) . rev( ) {
422- let __ai = Addrinfo :: default ( ) ;
423- * __ai. ai_socktype. borrow_mut( ) = __socktype;
424- * __ai. ai_protocol. borrow_mut( ) = __protocol;
425- let __storage = Ptr :: alloc( SockaddrStorage :: default ( ) ) ;
426- match __ip {
427- :: std:: net:: IpAddr :: V4 ( __v4) => {
428- * __ai. ai_family. borrow_mut( ) = :: libc:: AF_INET ;
429- * __ai. ai_addrlen. borrow_mut( ) =
430- :: std:: mem:: size_of:: <:: libc:: sockaddr_in>( ) as u32 ;
431- __storage
432- . reinterpret_cast:: <SockaddrIn >( )
433- . write( SockaddrIn :: from_ipv4( __v4, __port) ) ;
434- }
435- :: std:: net:: IpAddr :: V6 ( __v6) => {
436- * __ai. ai_family. borrow_mut( ) = :: libc:: AF_INET6 ;
437- * __ai. ai_addrlen. borrow_mut( ) =
438- :: std:: mem:: size_of:: <:: libc:: sockaddr_in6>( ) as u32 ;
439- __storage
440- . reinterpret_cast:: <SockaddrIn6 >( )
441- . write( SockaddrIn6 :: from_ipv6( __v6, __port) ) ;
442- }
443- }
444- * __ai. ai_addr. borrow_mut( ) = __storage. reinterpret_cast:: <Sockaddr >( ) ;
445- * __ai. ai_next. borrow_mut( ) = __next. clone( ) ;
446- __next = Ptr :: alloc( __ai) ;
447- }
448- __out. write( __next) ;
449- 0
450- }
451- } != 0 ) as i32 )
452- != 0 )
453- ) ;
454- }
455- pub fn test_null_hints_3 ( ) {
350+ pub fn test_null_hints_2 ( ) {
456351 let res: Value < Ptr < libcc2rs:: Addrinfo > > =
457352 Rc :: new ( RefCell :: new ( Ptr :: < libcc2rs:: Addrinfo > :: null ( ) ) ) ;
458353 assert ! (
@@ -588,7 +483,6 @@ pub fn main() {
588483fn main_0 ( ) -> i32 {
589484 ( { test_ipv4_literal_0 ( ) } ) ;
590485 ( { test_ipv6_literal_1 ( ) } ) ;
591- ( { test_family_mismatch_2 ( ) } ) ;
592- ( { test_null_hints_3 ( ) } ) ;
486+ ( { test_null_hints_2 ( ) } ) ;
593487 return 0 ;
594488}
0 commit comments