Unicodify InternetCheckConnection.
Use HeapAlloc'ed buffers where applicable.
This commit is contained in:
parent
c5789f8cfc
commit
522b39bb42
@ -2460,16 +2460,16 @@ BOOL WINAPI InternetTimeToSystemTimeW( LPCWSTR string, SYSTEMTIME* time, DWORD r
|
|||||||
}
|
}
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* InternetCheckConnectionA (WININET.@)
|
* InternetCheckConnectionW (WININET.@)
|
||||||
*
|
*
|
||||||
* Pings a requested host to check internet connection
|
* Pings a requested host to check internet connection
|
||||||
*
|
*
|
||||||
* RETURNS
|
* RETURNS
|
||||||
* TRUE on success and FALSE on failure. If a failure then
|
* TRUE on success and FALSE on failure. If a failure then
|
||||||
* ERROR_NOT_CONNECTED is placesd into GetLastError
|
* ERROR_NOT_CONNECTED is placed into GetLastError
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
|
BOOL WINAPI InternetCheckConnectionW( LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* this is a kludge which runs the resident ping program and reads the output.
|
* this is a kludge which runs the resident ping program and reads the output.
|
||||||
@ -2478,8 +2478,11 @@ BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwRes
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
BOOL rc = FALSE;
|
BOOL rc = FALSE;
|
||||||
char command[1024];
|
static const CHAR ping[] = "ping -w 1 ";
|
||||||
char host[1024];
|
static const CHAR redirect[] = " >/dev/null 2>/dev/null";
|
||||||
|
CHAR *command = NULL;
|
||||||
|
WCHAR hostW[1024];
|
||||||
|
DWORD len;
|
||||||
int status = -1;
|
int status = -1;
|
||||||
|
|
||||||
FIXME("\n");
|
FIXME("\n");
|
||||||
@ -2501,30 +2504,32 @@ BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwRes
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
URL_COMPONENTSA components;
|
URL_COMPONENTSW components;
|
||||||
|
|
||||||
ZeroMemory(&components,sizeof(URL_COMPONENTSA));
|
ZeroMemory(&components,sizeof(URL_COMPONENTSW));
|
||||||
components.lpszHostName = (LPSTR)&host;
|
components.lpszHostName = (LPWSTR)&hostW;
|
||||||
components.dwHostNameLength = 1024;
|
components.dwHostNameLength = 1024;
|
||||||
|
|
||||||
if (!InternetCrackUrlA(lpszUrl,0,0,&components))
|
if (!InternetCrackUrlW(lpszUrl,0,0,&components))
|
||||||
goto End;
|
goto End;
|
||||||
|
|
||||||
TRACE("host name : %s\n",components.lpszHostName);
|
TRACE("host name : %s\n",debugstr_w(components.lpszHostName));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Build our ping command
|
* Build our ping command
|
||||||
*/
|
*/
|
||||||
strcpy(command,"ping -w 1 ");
|
len = WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, NULL, 0, NULL, NULL);
|
||||||
strcat(command,host);
|
command = HeapAlloc( GetProcessHeap(), 0, strlen(ping)+len+strlen(redirect) );
|
||||||
strcat(command," >/dev/null 2>/dev/null");
|
strcpy(command,ping);
|
||||||
|
WideCharToMultiByte(CP_UNIXCP, 0, hostW, -1, command+strlen(ping), len, NULL, NULL);
|
||||||
|
strcat(command,redirect);
|
||||||
|
|
||||||
TRACE("Ping command is : %s\n",command);
|
TRACE("Ping command is : %s\n",command);
|
||||||
|
|
||||||
status = system(command);
|
status = system(command);
|
||||||
|
|
||||||
TRACE("Ping returned a code of %i \n",status);
|
TRACE("Ping returned a code of %i\n",status);
|
||||||
|
|
||||||
/* Ping return code of 0 indicates success */
|
/* Ping return code of 0 indicates success */
|
||||||
if (status == 0)
|
if (status == 0)
|
||||||
@ -2532,6 +2537,7 @@ BOOL WINAPI InternetCheckConnectionA( LPCSTR lpszUrl, DWORD dwFlags, DWORD dwRes
|
|||||||
|
|
||||||
End:
|
End:
|
||||||
|
|
||||||
|
HeapFree( GetProcessHeap(), 0, command );
|
||||||
if (rc == FALSE)
|
if (rc == FALSE)
|
||||||
SetLastError(ERROR_NOT_CONNECTED);
|
SetLastError(ERROR_NOT_CONNECTED);
|
||||||
|
|
||||||
@ -2540,7 +2546,7 @@ End:
|
|||||||
|
|
||||||
|
|
||||||
/***********************************************************************
|
/***********************************************************************
|
||||||
* InternetCheckConnectionW (WININET.@)
|
* InternetCheckConnectionA (WININET.@)
|
||||||
*
|
*
|
||||||
* Pings a requested host to check internet connection
|
* Pings a requested host to check internet connection
|
||||||
*
|
*
|
||||||
@ -2549,17 +2555,17 @@ End:
|
|||||||
* ERROR_NOT_CONNECTED is placed into GetLastError
|
* ERROR_NOT_CONNECTED is placed into GetLastError
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
BOOL WINAPI InternetCheckConnectionW(LPCWSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
|
BOOL WINAPI InternetCheckConnectionA(LPCSTR lpszUrl, DWORD dwFlags, DWORD dwReserved)
|
||||||
{
|
{
|
||||||
CHAR *szUrl;
|
WCHAR *szUrl;
|
||||||
INT len;
|
INT len;
|
||||||
BOOL rc;
|
BOOL rc;
|
||||||
|
|
||||||
len = WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, NULL, 0, NULL, NULL);
|
len = MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, NULL, 0);
|
||||||
if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(CHAR))))
|
if (!(szUrl = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR))))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
WideCharToMultiByte(CP_ACP, 0, lpszUrl, -1, szUrl, len, NULL, NULL);
|
MultiByteToWideChar(CP_ACP, 0, lpszUrl, -1, szUrl, len);
|
||||||
rc = InternetCheckConnectionA((LPCSTR)szUrl, dwFlags, dwReserved);
|
rc = InternetCheckConnectionW(szUrl, dwFlags, dwReserved);
|
||||||
HeapFree(GetProcessHeap(), 0, szUrl);
|
HeapFree(GetProcessHeap(), 0, szUrl);
|
||||||
|
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user