Report the error sent by the CGI script.

Make progress bar selection explicit.
oldstable
Ferenc Wagner 2004-02-21 04:01:56 +00:00 committed by Alexandre Julliard
parent 69880eb587
commit feaad968b8
3 changed files with 32 additions and 23 deletions

View File

@ -39,7 +39,7 @@ double progressScale;
/* Progress group counter for the gui* functions.
*/
int progressGroup = -1;
int progressGroup;
char *
renderString (va_list ap)
@ -90,7 +90,7 @@ guiStatus (va_list ap)
return 0;
}
/* report (R_PROGRESS, steps) */
/* report (R_PROGRESS, barnum, steps) */
int
textProgress (va_list ap)
{
@ -102,16 +102,18 @@ textProgress (va_list ap)
int
guiProgress (va_list ap)
{
unsigned int max = va_arg (ap, int);
HWND pb = GetDlgItem (dialog, IDC_PB0 + ++progressGroup * 2);
unsigned int max;
HWND pb;
progressMax = max;
progressGroup = va_arg (ap, int);
progressMax = max = va_arg (ap, int);
progressCurr = 0;
if (max > 0xffff) {
progressScale = (double)0xffff / max;
max = 0xffff;
}
else progressScale = 1;
pb = GetDlgItem (dialog, IDC_PB0 + progressGroup * 2);
SendMessage (pb, PBM_SETRANGE, 0, MAKELPARAM (0, max));
SendMessage (pb, PBM_SETSTEP, (WPARAM)1, 0);
return 0;

View File

@ -311,7 +311,7 @@ run_tests (char *logname, const char *tag)
wine_tests = xmalloc (nr_of_files * sizeof wine_tests[0]);
report (R_STATUS, "Extracting tests");
report (R_PROGRESS, nr_of_files);
report (R_PROGRESS, 0, nr_of_files);
for (i = 0; i < nr_of_files; i++) {
get_subtests (tempdir, wine_tests+i, i+1);
nr_of_tests += wine_tests[i].subtest_count;
@ -319,7 +319,7 @@ run_tests (char *logname, const char *tag)
report (R_DELTA, 0, "Extracting: Done");
report (R_STATUS, "Running tests");
report (R_PROGRESS, nr_of_tests);
report (R_PROGRESS, 1, nr_of_tests);
for (i = 0; i < nr_of_files; i++) {
struct wine_test *test = wine_tests + i;
int j;
@ -385,8 +385,7 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
submit = strtok (NULL, " ");
if (tag)
report (R_WARNING, "ignoring tag for submit");
if (send_file (submit))
report (R_ERROR, "can't submit file %s", submit);
send_file (submit);
break;
case 'o':
logname = strtok (NULL, " ");
@ -411,12 +410,10 @@ int WINAPI WinMain (HINSTANCE hInst, HINSTANCE hPrevInst,
if (!logname && !submit) {
report (R_STATUS, "Starting up");
logname = run_tests (NULL, tag);
if (report (R_ASK, MB_YESNO,
"Do you want to submit the test results?") == IDYES)
if (send_file (logname))
report (R_FATAL, "Can't submit logfile '%s'", logname);
if (remove (logname))
report (R_WARNING, "Can't remove logfile: %d.", errno);
if (report (R_ASK, MB_YESNO, "Do you want to submit the "
"test results?") == IDYES)
if (!send_file (logname) && remove (logname))
report (R_WARNING, "Can't remove logfile: %d.", errno);
free (logname);
report (R_STATUS, "Finished");
}

View File

@ -91,14 +91,15 @@ send_file (const char *name)
{
SOCKET s;
FILE *f;
unsigned char buffer[8192];
#define BUFLEN 8192
unsigned char *buffer;
size_t bytes_read, total, filesize;
char *str;
int ret;
/* RFC 2068 */
#define SEP "-"
const char head[] = "POST /~wferi/cgi-bin/winetests.cgi HTTP/1.0\r\n"
const char head[] = "POST /~wferi/cgi-bin/winetest.cgi HTTP/1.0\r\n"
"Host: afavant\r\n"
"User-Agent: Winetests Shell\r\n"
"Content-Type: multipart/form-data; boundary=" SEP "\r\n"
@ -111,6 +112,7 @@ send_file (const char *name)
"Upload File\r\n"
"--" SEP "--\r\n";
buffer = xmalloc (BUFLEN + 1);
s = open_http ("157.181.170.47");
if (s == INVALID_SOCKET) {
report (R_WARNING, "Can't open network connection: %d",
@ -145,8 +147,8 @@ send_file (const char *name)
}
report (R_STATUS, "Sending %u bytes of data", filesize);
report (R_PROGRESS, filesize);
while ((bytes_read = fread (buffer, 1, sizeof buffer / 8, f))) {
report (R_PROGRESS, 2, filesize);
while ((bytes_read = fread (buffer, 1, BUFLEN / 8, f))) {
if (send_buf (s, buffer, bytes_read)) {
report (R_WARNING, "Error sending body: %d, %d",
errno, WSAGetLastError ());
@ -164,15 +166,14 @@ send_file (const char *name)
report (R_DELTA, 0, "Network transfer: Done");
total = 0;
while ((bytes_read = recv (s, buffer + total,
sizeof buffer - total, 0))) {
while ((bytes_read = recv (s, buffer+total, BUFLEN-total, 0))) {
if ((signed)bytes_read == SOCKET_ERROR) {
report (R_WARNING, "Error receiving reply: %d, %d",
errno, WSAGetLastError ());
goto abort1;
}
total += bytes_read;
if (total == sizeof buffer) {
if (total == BUFLEN) {
report (R_WARNING, "Buffer overflow");
goto abort1;
}
@ -187,11 +188,20 @@ send_file (const char *name)
name, filesize);
ret = memcmp (str, buffer + total - bytes_read, bytes_read);
free (str);
return ret!=0;
if (ret) {
buffer[total] = 0;
str = strstr (buffer, "\r\n\r\n");
if (str) buffer = str + 4;
report (R_ERROR, "Can't submit logfile '%s'. "
"Server response: %s", name, buffer);
}
free (buffer);
return ret;
abort2:
fclose (f);
abort1:
close_http (s);
free (buffer);
return 1;
}