2 * Wininet - Utility functions
4 * Copyright 1999 Corel Corporation
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
34 #include "wine/debug.h"
37 WINE_DEFAULT_DEBUG_CHANNEL(wininet);
39 #define TIME_STRING_LEN 30
41 time_t ConvertTimeString(LPCSTR asctime)
43 char tmpChar[TIME_STRING_LEN];
46 int timelen = strlen(asctime);
48 if(!asctime || !timelen)
51 strncpy(tmpChar, asctime, TIME_STRING_LEN);
53 /* Assert that the string is the expected length */
54 if (tmpChar[TIME_STRING_LEN] != '\0')
56 tmpChar[TIME_STRING_LEN] = '\0';
60 /* Convert a time such as 'Mon, 15 Nov 1999 16:09:35 GMT' into a SYSTEMTIME structure
61 * We assume the time is in this format
62 * and divide it into easy to swallow chunks
72 t.tm_year = atoi(tmpChar+12) - 1900;
73 t.tm_mday = atoi(tmpChar+5);
74 t.tm_hour = atoi(tmpChar+17);
75 t.tm_min = atoi(tmpChar+20);
76 t.tm_sec = atoi(tmpChar+23);
79 tmpChar2 = tmpChar + 8;
126 BOOL GetAddress(LPCSTR lpszServerName, INTERNET_PORT nServerPort,
127 struct hostent **phe, struct sockaddr_in *psa)
131 TRACE("%s\n", lpszServerName);
133 /* Validate server name first
134 * Check if there is sth. like
135 * pinger.macromedia.com:80
136 * if yes, eliminate the :80....
138 found = strchr(lpszServerName, ':');
141 int len = found - lpszServerName;
142 char *new = HeapAlloc(GetProcessHeap(), 0, len + 1);
143 memcpy( new, lpszServerName, len );
145 TRACE("Found a ':' inside the server name, reparsed name: %s\n", new);
146 *phe = gethostbyname(new);
147 HeapFree( GetProcessHeap(), 0, new );
149 else *phe = gethostbyname(lpszServerName);
153 TRACE("Failed to get hostname: (%s)\n", lpszServerName);
157 memset(psa,0,sizeof(struct sockaddr_in));
158 memcpy((char *)&psa->sin_addr, (*phe)->h_addr, (*phe)->h_length);
159 psa->sin_family = (*phe)->h_addrtype;
160 psa->sin_port = htons((u_short)nServerPort);