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)
118 TRACE("%s\n", lpszServerName);
120 /* Validate server name first
121 * Check if there is sth. like
122 * pinger.macromedia.com:80
123 * if yes, eliminate the :80....
125 found = strchr(lpszServerName, ':');
128 int len = found - lpszServerName;
129 char *new = HeapAlloc(GetProcessHeap(), 0, len + 1);
130 memcpy( new, lpszServerName, len );
132 TRACE("Found a ':' inside the server name, reparsed name: %s\n", new);
133 *phe = gethostbyname(new);
134 HeapFree( GetProcessHeap(), 0, new );
136 else *phe = gethostbyname(lpszServerName);
140 TRACE("Failed to get hostname: (%s)\n", lpszServerName);
144 memset(psa,0,sizeof(struct sockaddr_in));
145 memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
146 psa->sin_family = (*phe)->h_addrtype;
147 psa->sin_port = htons((u_short)nServerPort);