1*8fdd821aSDavid Carlier // RUN: %clangxx -O0 -g %s -o %t 2*8fdd821aSDavid Carlier // 3*8fdd821aSDavid Carlier // REQUIRES: linux, freebsd 4339f1b49SGui Andrade 5339f1b49SGui Andrade #include <netdb.h> 6339f1b49SGui Andrade #include <stdio.h> 7*8fdd821aSDavid Carlier #include <stdlib.h> 8*8fdd821aSDavid Carlier #include <assert.h> 91bbed690SVitaly Buka test1()10*8fdd821aSDavid Carliervoid test1() { 11*8fdd821aSDavid Carlier struct protoent *ptp = getprotoent(); 12*8fdd821aSDavid Carlier assert(ptp && ptp->p_name); 13*8fdd821aSDavid Carlier assert(ptp->p_proto == 0); 14*8fdd821aSDavid Carlier endprotoent(); 15339f1b49SGui Andrade } 16339f1b49SGui Andrade test2()17*8fdd821aSDavid Carliervoid test2() { 18*8fdd821aSDavid Carlier struct protoent *ptp = getprotobyname("tcp"); 19*8fdd821aSDavid Carlier assert(ptp && ptp->p_name); 20*8fdd821aSDavid Carlier assert(ptp->p_proto == 6); 21*8fdd821aSDavid Carlier endprotoent(); 22339f1b49SGui Andrade } 23339f1b49SGui Andrade test3()24*8fdd821aSDavid Carliervoid test3() { 25*8fdd821aSDavid Carlier struct protoent *ptp = getprotobynumber(1); 26*8fdd821aSDavid Carlier assert(ptp && ptp->p_name); 27*8fdd821aSDavid Carlier assert(ptp->p_proto == 1); 28*8fdd821aSDavid Carlier endprotoent(); 29339f1b49SGui Andrade } 30339f1b49SGui Andrade test4()31*8fdd821aSDavid Carliervoid test4() { 32*8fdd821aSDavid Carlier setprotoent(1); 33*8fdd821aSDavid Carlier struct protoent *ptp = getprotobynumber(1); 34339f1b49SGui Andrade 35*8fdd821aSDavid Carlier ptp = getprotobynumber(2); 36*8fdd821aSDavid Carlier assert(ptp && ptp->p_name); 37*8fdd821aSDavid Carlier assert(ptp->p_proto == 2); 38*8fdd821aSDavid Carlier endprotoent(); 39339f1b49SGui Andrade } 40339f1b49SGui Andrade main(void)41*8fdd821aSDavid Carlierint main(void) { 42*8fdd821aSDavid Carlier printf("protoent\n"); 43339f1b49SGui Andrade 44*8fdd821aSDavid Carlier test1(); 45*8fdd821aSDavid Carlier test2(); 46*8fdd821aSDavid Carlier test3(); 47*8fdd821aSDavid Carlier test4(); 481bbed690SVitaly Buka 49339f1b49SGui Andrade return 0; 50339f1b49SGui Andrade } 51