File diff r4320:c2a7d05512a6 → r4321:baa916e5dd65
win32.c
Show inline comments
 
@@ -244,49 +244,49 @@ static const char wininet_files[] =
 
static WinInetProcs _wininet;
 

	
 

	
 
static const char *SubmitCrashReport(HWND wnd, void *msg, size_t msglen, const char *arg)
 
{
 
	HINTERNET inet, conn, http;
 
	const char *err = NULL;
 
	DWORD code, len;
 
	static char buf[100];
 
	char buff[100];
 

	
 
	if (_wininet.InternetOpen == NULL && !LoadLibraryList((Function*)&_wininet, wininet_files)) return "can't load wininet.dll";
 

	
 
	inet = _wininet.InternetOpen("OTTD", INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0 );
 
	if (inet == NULL) { err = "internetopen failed"; goto error1; }
 

	
 
	conn = _wininet.InternetConnect(inet, "openttd.com", INTERNET_DEFAULT_HTTP_PORT, "", "", INTERNET_SERVICE_HTTP, 0, 0);
 
	if (conn == NULL) { err = "internetconnect failed"; goto error2; }
 

	
 
	sprintf(buff, "/crash.php?file=%s&ident=%d", arg, _ident);
 

	
 
	http = _wininet.HttpOpenRequest(conn, "POST", buff, NULL, NULL, NULL, INTERNET_FLAG_NO_CACHE_WRITE , 0);
 
	if (http == NULL) { err = "httpopenrequest failed"; goto error3; }
 

	
 
	if (!_wininet.HttpSendRequest(http, "Content-type: application/binary", -1, msg, msglen)) { err = "httpsendrequest failed"; goto error4; }
 
	if (!_wininet.HttpSendRequest(http, "Content-type: application/binary", -1, msg, (DWORD)msglen)) { err = "httpsendrequest failed"; goto error4; }
 

	
 
	len = sizeof(code);
 
	if (!_wininet.HttpQueryInfo(http, HTTP_QUERY_STATUS_CODE | HTTP_QUERY_FLAG_NUMBER, &code, &len, 0)) { err = "httpqueryinfo failed"; goto error4; }
 

	
 
	if (code != 200) {
 
		int l = sprintf(buf, "Server said: %d ", code);
 
		len = sizeof(buf) - l;
 
		_wininet.HttpQueryInfo(http, HTTP_QUERY_STATUS_TEXT, buf + l, &len, 0);
 
		err = buf;
 
	}
 

	
 
error4:
 
	_wininet.InternetCloseHandle(http);
 
error3:
 
	_wininet.InternetCloseHandle(conn);
 
error2:
 
	_wininet.InternetCloseHandle(inet);
 
error1:
 
	return err;
 
}
 

	
 
static void SubmitFile(HWND wnd, const char *file)
 
{
 
	HANDLE h;