ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libukcprog/src/ip.c
(Generate patch)

Comparing projects/libukcprog/src/ip.c (file contents):
Revision 1.1 by tdb, Sat Mar 29 16:30:33 2003 UTC vs.
Revision 1.2 by tdb, Sat Sep 24 13:31:30 2005 UTC

# Line 16 | Line 16 | char ukcprog_ip_sccsid[] = "$Id$ UKC";
16   #else
17   #include <sys/tk_types.h>
18   #endif
19 + #ifndef WIN32
20   #include <sys/socket.h>
21   #include <netinet/in.h>
22   #include <netdb.h>
23 + #else
24 + #include <winsock2.h>
25 + #endif
26  
27   #include <stdlib.h>
28   #include <string.h>
# Line 41 | Line 45 | struct in_addr *p_addr;
45          char c;
46  
47          if (sscanf(hostname, "%d.%d.%d.%d%c", &b3, &b2, &b1, &b0, &c) == 4) {
48 <                 unsigned long val;
48 >                unsigned long val;
49  
50 <                 val = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
51 <                 p_addr->s_addr = htonl(val);
52 <                 return 0;
50 >                val = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0;
51 >                p_addr->s_addr = htonl(val);
52 >                return 0;
53          }
54  
55 + #ifdef WIN32
56 +        /* Init the winsock, because we all love windows */
57 +        WSADATA wsaData;
58 +
59 +        if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) {
60 +                errf("Unable to init a winsock");
61 +                return -1;
62 +        }
63 + #endif
64          if ((h = gethostbyname(hostname)) == NULL) {
65                  errf("Can't find address of %s", hostname);
66                  return -1;
# Line 80 | Line 93 | int *p_port;
93                  *p_port = htons(hport);
94                  return 0;
95          }
96 +
97 + #ifdef WIN32
98 +        /* Init the winsock, because we all love windows */
99 +        WSADATA wsaData;
100 +
101 +        if(WSAStartup(MAKEWORD(2,2), &wsaData) != NO_ERROR) {
102 +                errf("Unable to init a winsock");
103 +                return -1;
104 +        }
105 + #endif
106  
107          if ((sp = getservbyname(servname, "tcp")) == NULL) {
108                  errf("Unknown service `%s'", servname);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines