2 * Wininet - Utility functions
4 * Copyright 1999 Corel Corporation
21 #include "debugtools.h"
24 DEFAULT_DEBUG_CHANNEL(wininet
);
26 #define TIME_STRING_LEN 30
28 time_t ConvertTimeString(LPCSTR asctime
)
30 char tmpChar
[TIME_STRING_LEN
];
33 int timelen
= strlen(asctime
);
35 if(!asctime
|| !timelen
)
38 strncpy(tmpChar
, asctime
, TIME_STRING_LEN
);
40 /* Assert that the string is the expected length */
41 if (tmpChar
[TIME_STRING_LEN
] != '\0')
43 tmpChar
[TIME_STRING_LEN
] = '\0';
47 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
48 * We assume the time is in this format
49 * and divide it into easy to swallow chunks
59 t
.tm_year
= atoi(tmpChar
+12) - 1900;
60 t
.tm_mday
= atoi(tmpChar
+5);
61 t
.tm_hour
= atoi(tmpChar
+17);
62 t
.tm_min
= atoi(tmpChar
+20);
63 t
.tm_sec
= atoi(tmpChar
+23);
66 tmpChar2
= tmpChar
+ 8;
113 BOOL
GetAddress(LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
114 struct hostent
**phe
, struct sockaddr_in
*psa
)
116 TRACE("%s\n", lpszServerName
);
118 *phe
= gethostbyname(lpszServerName
);
121 TRACE("Failed to get hostname: (%s)\n", lpszServerName
);
125 memset(psa
,0,sizeof(struct sockaddr_in
));
126 memcpy((char *)&psa
->sin_addr
, (*phe
)->h_addr
, (*phe
)->h_length
);
127 psa
->sin_family
= (*phe
)->h_addrtype
;
128 psa
->sin_port
= htons((u_short
)nServerPort
);