2 * Wininet - Utility functions
4 * Copyright 1999 Corel Corporation
19 #include "debugtools.h"
22 DEFAULT_DEBUG_CHANNEL(wininet
);
24 #define TIME_STRING_LEN 30
26 time_t ConvertTimeString(LPCSTR asctime
)
28 char tmpChar
[TIME_STRING_LEN
];
31 int timelen
= strlen(asctime
);
33 if(!asctime
|| !timelen
)
36 strncpy(tmpChar
, asctime
, TIME_STRING_LEN
);
38 /* Assert that the string is the expected length */
39 if (tmpChar
[TIME_STRING_LEN
] != '\0')
41 tmpChar
[TIME_STRING_LEN
] = '\0';
45 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
46 * We assume the time is in this format
47 * and divide it into easy to swallow chunks
57 SystemTime
.tm_year
= atoi(tmpChar
+12) - 1900;
58 SystemTime
.tm_mday
= atoi(tmpChar
+5);
59 SystemTime
.tm_hour
= atoi(tmpChar
+17);
60 SystemTime
.tm_min
= atoi(tmpChar
+20);
61 SystemTime
.tm_sec
= atoi(tmpChar
+23);
64 tmpChar2
= tmpChar
+ 8;
69 SystemTime
.tm_mon
= 0;
71 SystemTime
.tm_mon
= 5;
74 SystemTime
.tm_mon
= 1;
78 SystemTime
.tm_mon
= 2;
80 SystemTime
.tm_mon
= 3;
83 SystemTime
.tm_mon
= 4;
86 SystemTime
.tm_mon
= 6;
89 SystemTime
.tm_mon
= 7;
92 SystemTime
.tm_mon
= 8;
95 SystemTime
.tm_mon
= 9;
98 SystemTime
.tm_mon
= 10;
101 SystemTime
.tm_mon
= 11;
107 return mktime(&SystemTime
);
111 BOOL
GetAddress(LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
112 struct hostent
**phe
, struct sockaddr_in
*psa
)
114 *phe
= gethostbyname(lpszServerName
);
117 TRACE("Failed to get hostname %s\n", lpszServerName
);
121 memset(psa
,0,sizeof(struct sockaddr_in
));
122 memcpy((char *)&psa
->sin_addr
, (*phe
)->h_addr
, (*phe
)->h_length
);
123 psa
->sin_family
= (*phe
)->h_addrtype
;
124 psa
->sin_port
= htons((u_short
)nServerPort
);