summary refs log tree commit diff stats
path: root/src/fe-gtk/check-version.c
blob: 675ef3fb5c8d5c0bc6945e267621d029bf200ef3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#include <windows.h>
#include <wininet.h>

char* check_version ()
{
	HINTERNET hINet, hFile;
	hINet = InternetOpen("XChat-WDK Update Checker", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
	
	if (!hINet)
	{
		return "unavailable";
	}

	hFile = InternetOpenUrl (hINet, "http://xchat-wdk.googlecode.com/hg/version.txt", NULL, 0, 0, 0);
	
	if (hFile)
	{
		static char buffer[1024];
		DWORD dwRead;
		while (InternetReadFile(hFile, buffer, 1023, &dwRead))
		{
			if (dwRead == 0)
			{
				break;
			}
			buffer[dwRead] = 0;
		}
		
		return buffer;
		InternetCloseHandle (hFile);
	}
	
	InternetCloseHandle (hINet);

	return "unavailable";
}