2 * Wininet - Utility functions
4 * Copyright 1999 Corel Corporation
22 #include "debugtools.h"
25 DEFAULT_DEBUG_CHANNEL(wininet
);
27 #define TIME_STRING_LEN 30
29 time_t ConvertTimeString(LPCSTR asctime
)
31 char tmpChar
[TIME_STRING_LEN
];
34 int timelen
= strlen(asctime
);
36 if(!asctime
|| !timelen
)
39 strncpy(tmpChar
, asctime
, TIME_STRING_LEN
);
41 /* Assert that the string is the expected length */
42 if (tmpChar
[TIME_STRING_LEN
] != '\0')
44 tmpChar
[TIME_STRING_LEN
] = '\0';
48 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
49 * We assume the time is in this format
50 * and divide it into easy to swallow chunks
60 SystemTime
.tm_year
= atoi(tmpChar
+12) - 1900;
61 SystemTime
.tm_mday
= atoi(tmpChar
+5);
62 SystemTime
.tm_hour
= atoi(tmpChar
+17);
63 SystemTime
.tm_min
= atoi(tmpChar
+20);
64 SystemTime
.tm_sec
= atoi(tmpChar
+23);
67 tmpChar2
= tmpChar
+ 8;
72 SystemTime
.tm_mon
= 0;
74 SystemTime
.tm_mon
= 5;
77 SystemTime
.tm_mon
= 1;
81 SystemTime
.tm_mon
= 2;
83 SystemTime
.tm_mon
= 3;
86 SystemTime
.tm_mon
= 4;
89 SystemTime
.tm_mon
= 6;
92 SystemTime
.tm_mon
= 7;
95 SystemTime
.tm_mon
= 8;
98 SystemTime
.tm_mon
= 9;
101 SystemTime
.tm_mon
= 10;
104 SystemTime
.tm_mon
= 11;
110 return mktime(&SystemTime
);
114 BOOL
GetAddress(LPCSTR lpszServerName
, INTERNET_PORT nServerPort
,
115 struct hostent
**phe
, struct sockaddr_in
*psa
)
117 TRACE("%s\n", lpszServerName
);
119 *phe
= gethostbyname(lpszServerName
);
122 TRACE("Failed to get hostname: (%s)\n", lpszServerName
);
126 memset(psa
,0,sizeof(struct sockaddr_in
));
127 memcpy((char *)&psa
->sin_addr
, (*phe
)->h_addr
, (*phe
)->h_length
);
128 psa
->sin_family
= (*phe
)->h_addrtype
;
129 psa
->sin_port
= htons((u_short
)nServerPort
);