Coccinelle release 0.2.5-rc3
[bpt/coccinelle.git] / tests / not_converted_ver1.c
CommitLineData
b1b2de81
C
1// -ifdef_to_if doesn't convert this ifdef
2
3static int do_accept(int acc_sock, int *sock, char **host)
4 {
5 int ret,i;
6 struct hostent *h1,*h2;
7 static struct sockaddr_in from;
8 int len;
9/* struct linger ling; */
10
11 if (!ssl_sock_init()) return(0);
12
13#ifndef OPENSSL_SYS_WINDOWS
14redoit:
15#endif
16
17 memset((char *)&from,0,sizeof(from));
18 len=sizeof(from);
19 /* Note: under VMS with SOCKETSHR the fourth parameter is currently
20 * of type (int *) whereas under other systems it is (void *) if
21 * you don't have a cast it will choke the compiler: if you do
22 * have a cast then you can either go for (int *) or (void *).
23 */
24 ret=accept(acc_sock,(struct sockaddr *)&from,(void *)&len);
25 if (ret == INVALID_SOCKET)
26 {
27#if defined(OPENSSL_SYS_WINDOWS) || (defined(OPENSSL_SYS_NETWARE) && !defined(NETWARE_BSDSOCK))
28 i=WSAGetLastError();
29 BIO_printf(bio_err,"accept error %d\n",i);
30#else
31 if (errno == EINTR)
32 {
33 /*check_timeout(); */
34 goto redoit;
35 }
36 fprintf(stderr,"errno=%d ",errno);
37 perror("accept");
38#endif
39 return(0);
40 }
41
42/*
43 ling.l_onoff=1;
44 ling.l_linger=0;
45 i=setsockopt(ret,SOL_SOCKET,SO_LINGER,(char *)&ling,sizeof(ling));
46 if (i < 0) { perror("linger"); return(0); }
47 i=0;
48 i=setsockopt(ret,SOL_SOCKET,SO_KEEPALIVE,(char *)&i,sizeof(i));
49 if (i < 0) { perror("keepalive"); return(0); }
50*/
51
52 if (host == NULL) goto end;
53#ifndef BIT_FIELD_LIMITS
54 /* I should use WSAAsyncGetHostByName() under windows */
55 h1=gethostbyaddr((char *)&from.sin_addr.s_addr,
56 sizeof(from.sin_addr.s_addr),AF_INET);
57#else
58 h1=gethostbyaddr((char *)&from.sin_addr,
59 sizeof(struct in_addr),AF_INET);
60#endif
61 if (h1 == NULL)
62 {
63 BIO_printf(bio_err,"bad gethostbyaddr\n");
64 *host=NULL;
65 /* return(0); */
66 }
67 else
68 {
69 if ((*host=(char *)OPENSSL_malloc(strlen(h1->h_name)+1)) == NULL)
70 {
71 perror("OPENSSL_malloc");
72 return(0);
73 }
74 BUF_strlcpy(*host,h1->h_name,strlen(h1->h_name)+1);
75
76 h2=GetHostByName(*host);
77 if (h2 == NULL)
78 {
79 BIO_printf(bio_err,"gethostbyname failure\n");
80 return(0);
81 }
82 i=0;
83 if (h2->h_addrtype != AF_INET)
84 {
85 BIO_printf(bio_err,"gethostbyname addr is not AF_INET\n");
86 return(0);
87 }
88 }
89end:
90 *sock=ret;
91 return(1);
92 }