Commit 354f6629 authored by Ferenc Wagner's avatar Ferenc Wagner Committed by Alexandre Julliard

Added graphical feedback.

parent 6c08994c
Makefile
gui.res
wine.ico
winetest.exe.dbg.c
winetest.exe.spec.c
winetest.rc
......
......@@ -4,14 +4,20 @@ SRCDIR = @srcdir@
VPATH = @srcdir@
MODULE = winetest.exe
APPMODE = gui
IMPORTS = user32 wsock32
IMPORTS = comctl32 user32 wsock32
C_SRCS = \
gui.c \
main.c \
send.c \
util.c
RC_SRCS = winetest.rc
RC_SRCS = \
gui.rc \
winetest.rc
RC_BINSRC = gui.rc
RC_BINARIES = wine.ico
TESTS = \
advapi32 \
......
/*
* GUI support
*
* Copyright 2004 Ferenc Wagner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
*
*/
#include <windows.h>
#include <commctrl.h>
#include "guires.h"
#include "winetest.h"
/* Event object to signal successful window creation to main thread.
*/
HANDLE initEvent;
/* Dialog handle
*/
HWND dialog;
/* Progress data for the text* functions and for scaling.
*/
unsigned int progressMax, progressCurr;
double progressScale;
/* Progress group counter for the gui* functions.
*/
int progressGroup = -1;
char *
renderString (va_list ap)
{
const char *fmt = va_arg (ap, char*);
static char buffer[128];
vsnprintf (buffer, sizeof buffer, fmt, ap);
return buffer;
}
/* report (R_STATUS, fmt, ...) */
int
textStatus (va_list ap)
{
char *str = vstrmake (NULL, ap);
fputs (str, stderr);
fputc ('\n', stderr);
free (str);
return 0;
}
int
guiStatus (va_list ap)
{
size_t len;
char *str = vstrmake (&len, ap);
if (len > 128) str[129] = 0;
SetDlgItemText (dialog, IDC_SB, str);
free (str);
return 0;
}
/* report (R_PROGRESS, steps) */
int
textProgress (va_list ap)
{
progressMax = va_arg (ap, int);
progressCurr = 0;
return 0;
}
int
guiProgress (va_list ap)
{
unsigned int max = va_arg (ap, int);
HWND pb = GetDlgItem (dialog, IDC_PB0 + ++progressGroup * 2);
progressMax = max;
progressCurr = 0;
if (max > 0xffff) {
progressScale = (double)0xffff / max;
max = 0xffff;
}
else progressScale = 1;
SendMessage (pb, PBM_SETRANGE, 0, MAKELPARAM (0, max));
SendMessage (pb, PBM_SETSTEP, (WPARAM)1, 0);
return 0;
}
/* report (R_STEP, fmt, ...) */
int
textStep (va_list ap)
{
char *str = vstrmake (NULL, ap);
progressCurr++;
fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
free (str);
return 0;
}
int
guiStep (va_list ap)
{
const int pgID = IDC_ST0 + progressGroup * 2;
char *str = vstrmake (NULL, ap);
progressCurr++;
SetDlgItemText (dialog, pgID, str);
SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
(WPARAM)(progressScale * progressCurr), 0);
free (str);
return 0;
}
/* report (R_DELTA, inc, fmt, ...) */
int
textDelta (va_list ap)
{
const int inc = va_arg (ap, int);
char *str = vstrmake (NULL, ap);
progressCurr += inc;
fputs (str, stderr);
fprintf (stderr, " (%d of %d)\n", progressCurr, progressMax);
free (str);
return 0;
}
int
guiDelta (va_list ap)
{
const int inc = va_arg (ap, int);
const int pgID = IDC_ST0 + progressGroup * 2;
char *str = vstrmake (NULL, ap);
progressCurr += inc;
SetDlgItemText (dialog, pgID, str);
SendDlgItemMessage (dialog, pgID+1, PBM_SETPOS,
(WPARAM)(progressScale * progressCurr), 0);
free (str);
return 0;
}
/* report (R_DIR, fmt, ...) */
int
textDir (va_list ap)
{
char *str = vstrmake (NULL, ap);
fputs ("Temporary directory: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
free (str);
return 0;
}
int
guiDir (va_list ap)
{
char *str = vstrmake (NULL, ap);
SetDlgItemText (dialog, IDC_DIR, str);
free (str);
return 0;
}
/* report (R_OUT, fmt, ...) */
int
textOut (va_list ap)
{
char *str = vstrmake (NULL, ap);
fputs ("Log file: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
free (str);
return 0;
}
int
guiOut (va_list ap)
{
char *str = vstrmake (NULL, ap);
SetDlgItemText (dialog, IDC_OUT, str);
free (str);
return 0;
}
/* report (R_FATAL, fmt, ...) */
int
textFatal (va_list ap)
{
char *str = vstrmake (NULL, ap);
fputs ("Fatal error: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
free (str);
exit (1);
}
int
guiFatal (va_list ap)
{
char *str = vstrmake (NULL, ap);
MessageBox (dialog, str, "Fatal Error", MB_ICONERROR | MB_OK);
free (str);
exit (1);
}
/* report (R_WARNING, fmt, ...) */
int
textWarning (va_list ap)
{
char *str = vstrmake (NULL, ap);
fputs ("Warning: ", stderr);
fputs (str, stderr);
fputc ('\n', stderr);
free (str);
return 0;
}
int
guiWarning (va_list ap)
{
char *str = vstrmake (NULL, ap);
MessageBox (dialog, str, "Warning", MB_ICONWARNING | MB_OK);
free (str);
return 0;
}
/* report (R_ASK, type, fmt, ...) */
int
textAsk (va_list ap)
{
int uType = va_arg (ap, int);
char *str = vstrmake (NULL, ap);
fprintf (stderr, "Question of type %d: %s\n!FIXME, stub\n",
uType, str);
free (str);
return 0;
}
int
guiAsk (va_list ap)
{
int uType = va_arg (ap, int);
char *str = vstrmake (NULL, ap);
int ret = MessageBox (dialog, str, "Question",
MB_ICONQUESTION | uType);
free (str);
return ret;
}
BOOL CALLBACK
AboutProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_COMMAND:
switch (LOWORD (wParam)) {
case IDCANCEL:
EndDialog (hwnd, IDCANCEL);
return TRUE;
}
}
return FALSE;
}
BOOL CALLBACK
DlgProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg) {
case WM_INITDIALOG:
SendMessage (hwnd, WM_SETICON, ICON_SMALL,
(LPARAM)LoadIcon (GetModuleHandle (NULL),
MAKEINTRESOURCE (IDI_WINE)));
SendMessage (hwnd, WM_SETICON, ICON_BIG,
(LPARAM)LoadIcon (GetModuleHandle (NULL),
MAKEINTRESOURCE (IDI_WINE)));
dialog = hwnd;
if (!SetEvent (initEvent)) {
report (R_STATUS, "Can't signal main thread: %d",
GetLastError ());
EndDialog (hwnd, 2);
}
return TRUE;
case WM_CLOSE:
EndDialog (hwnd, 3);
return TRUE;
case WM_COMMAND:
switch (LOWORD (wParam)) {
case IDHELP:
DialogBox (GetModuleHandle (NULL),
MAKEINTRESOURCE (IDD_ABOUT), hwnd, AboutProc);
return TRUE;
case IDABORT:
report (R_WARNING, "Not implemented");
return TRUE;
}
}
return FALSE;
}
DWORD WINAPI
DlgThreadProc ()
{
int ret;
InitCommonControls ();
ret = DialogBox (GetModuleHandle (NULL),
MAKEINTRESOURCE (IDD_STATUS),
NULL, DlgProc);
switch (ret) {
case 0:
report (R_WARNING, "Invalid parent handle");
break;
case 1:
report (R_WARNING, "DialogBox failed: %d",
GetLastError ());
break;
case 3:
exit (0);
default:
report (R_STATUS, "Dialog exited: %d", ret);
}
return 0;
}
int
report (enum report_type t, ...)
{
typedef int r_fun_t (va_list);
va_list ap;
int ret = 0;
static r_fun_t * const text_funcs[] =
{textStatus, textProgress, textStep, textDelta,
textDir, textOut, textFatal, textWarning, textAsk};
static r_fun_t * const GUI_funcs[] =
{guiStatus, guiProgress, guiStep, guiDelta,
guiDir, guiOut, guiFatal, guiWarning, guiAsk};
static r_fun_t * const * funcs = NULL;
if (!funcs) {
HANDLE DlgThread;
DWORD DlgThreadID;
funcs = text_funcs;
initEvent = CreateEvent (NULL, FALSE, FALSE, NULL);
if (!initEvent)
report (R_STATUS, "Can't create event object: %d",
GetLastError ());
else {
DlgThread = CreateThread (NULL, 0, DlgThreadProc,
NULL, 0, &DlgThreadID);
if (!DlgThread)
report (R_STATUS, "Can't create GUI thread: %d",
GetLastError ());
else {
DWORD ret = WaitForSingleObject (initEvent, INFINITE);
switch (ret) {
case WAIT_OBJECT_0:
funcs = GUI_funcs;
break;
case WAIT_TIMEOUT:
report (R_STATUS, "GUI creation timed out");
break;
case WAIT_FAILED:
report (R_STATUS, "Wait for GUI failed: %d",
GetLastError ());
break;
default:
report (R_STATUS, "Wait returned %d",
ret);
break;
}
}
}
}
va_start (ap, t);
if (t < sizeof text_funcs / sizeof text_funcs[0] &&
t < sizeof GUI_funcs / sizeof GUI_funcs[0] &&
t >= 0) ret = funcs[t](ap);
else report (R_WARNING, "unimplemented report type: %d", t);
va_end (ap);
return ret;
}
/*
* GUI resources
*
* Copyright 2004 Ferenc Wagner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
*
*/
#include <windows.h>
#include <winres.h>
#include "guires.h"
IDD_STATUS DIALOG 0, 0, 160, 140
STYLE WS_OVERLAPPEDWINDOW
CAPTION "Wine Test Shell"
BEGIN
LTEXT "Extracting:", IDC_ST0, 10, 5, 140, 10
CONTROL "PB0", IDC_PB0, PROGRESS_CLASS, 0, 5, 15, 150, 10
LTEXT "Running:", IDC_ST1, 10, 30, 140, 10
CONTROL "PB1", IDC_PB1, PROGRESS_CLASS, 0, 5, 40, 150, 15
LTEXT "Network transfer:", IDC_ST2, 10, 60, 140, 10
CONTROL "PB2", IDC_PB2, PROGRESS_CLASS, 0, 5, 70, 150, 10
LTEXT "Working directory:", IDC_STATIC, 10, 89, 100, 10
EDITTEXT IDC_DIR, 71, 88, 79, 10,
ES_READONLY | ES_AUTOHSCROLL
LTEXT "Output file:", IDC_STATIC, 10, 100, 100, 10
EDITTEXT IDC_OUT, 46, 99, 104, 10,
ES_READONLY | ES_AUTOHSCROLL
DEFPUSHBUTTON "About", IDHELP, 20, 113, 30, 14
PUSHBUTTON "Edit", IDCANCEL, 65, 113, 30, 14,
WS_DISABLED
PUSHBUTTON "Stop", IDABORT, 110, 113, 30, 14
CONTROL "Created", IDC_SB, STATUSCLASSNAME, 0, 0,0,0,0
END
IDD_ABOUT DIALOG 0, 0, 150, 55
STYLE WS_POPUP
CAPTION "About Wine Test Shell"
BEGIN
CTEXT "This program extracts and runs a\r\nseries of tests which check Wine's\r\nconformance to Microsoft Windows.",
IDC_STATIC, 10, 5, 130, 30
DEFPUSHBUTTON "Close", IDCANCEL, 55, 35, 40, 14
END
/* BINRES wine.ico */
IDI_WINE ICON "wine.ico"
/* {
'00 00 01 00 02 00 20 20 10 00 00 00 00 00 E8 02'
'00 00 26 00 00 00 10 10 10 00 00 00 00 00 28 01'
'00 00 0E 03 00 00 28 00 00 00 20 00 00 00 40 00'
'00 00 01 00 04 00 00 00 00 00 00 02 00 00 00 00'
'00 00 00 00 00 00 10 00 00 00 00 00 00 00 39 02'
'B1 00 23 02 6C 00 0F 03 29 00 1B 02 51 00 FF FF'
'FF 00 1B 1A 1B 00 1E 02 63 00 33 02 A1 00 08 08'
'08 00 14 03 3C 00 0C 04 1E 00 2E 02 8E 00 10 0F'
'10 00 2A 02 82 00 29 02 7D 00 03 02 04 00 44 44'
'44 44 44 44 44 44 55 44 44 44 44 44 44 44 44 44'
'44 44 44 44 8F FF 84 44 44 44 44 44 44 44 44 44'
'44 44 44 8F F8 F8 44 44 44 44 44 44 44 44 44 44'
'44 44 8F FF F5 44 44 44 44 44 44 44 44 44 44 44'
'44 5C F8 C8 F5 44 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 85 44 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 4C 44 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 4C 44 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 45 54 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 45 F4 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 45 FF 44 44 44 44 44 44 44 44 44 44'
'44 44 44 44 48 FF F4 44 44 44 44 44 44 44 44 44'
'44 44 44 44 48 23 9A 84 44 44 44 44 44 44 44 44'
'44 44 44 44 42 B7 7E AF 44 44 44 44 44 44 44 44'
'44 44 44 44 49 00 00 EA C4 44 44 44 44 44 44 44'
'44 44 44 44 46 00 00 01 F4 44 44 44 44 44 44 44'
'44 44 44 44 46 00 00 00 9F 44 44 44 44 44 44 44'
'44 44 44 44 46 00 70 00 EF 44 44 44 44 44 44 44'
'44 44 44 44 43 00 00 00 79 F4 44 44 44 44 44 44'
'44 44 44 44 49 00 00 00 0E F4 44 44 44 44 44 44'
'44 44 44 44 42 00 00 00 07 24 44 44 44 44 44 44'
'44 44 44 44 43 B0 00 00 00 34 44 44 44 44 44 44'
'44 44 44 44 4C 30 00 00 00 1F 44 44 44 44 44 44'
'44 44 44 44 48 27 E1 1D B1 2C 44 44 44 44 44 44'
'44 44 44 44 44 A9 CC CF F8 48 C4 44 44 44 44 44'
'44 44 44 44 44 58 44 44 44 45 C4 44 44 44 44 44'
'44 44 44 44 44 4C 44 44 44 44 84 44 44 44 44 44'
'44 44 44 44 44 48 44 44 44 44 C4 44 44 44 44 44'
'44 44 44 44 44 48 C4 44 44 44 C4 44 44 44 44 44'
'44 44 44 44 44 44 F4 44 44 4C C4 44 44 44 44 44'
'44 44 44 44 44 44 84 44 F8 84 44 44 44 44 44 44'
'44 44 44 44 44 44 48 F8 44 44 44 44 44 44 FF FF'
'3F FF FF F0 7F FF FF C0 FF FF FF 03 FF FF FC 03'
'FF FF FF F3 FF FF FF FB FF FF FF FB FF FF FF F9'
'FF FF FF F9 FF FF FF F8 FF FF FF F8 7F FF FF F8'
'1F FF FF F8 0F FF FF F8 07 FF FF F8 07 FF FF F8'
'03 FF FF F8 03 FF FF F8 01 FF FF F8 01 FF FF F8'
'01 FF FF F8 01 FF FF F8 00 FF FF F8 00 FF FF FC'
'02 7F FF FC FE 7F FF FE FF 7F FF FE FF 7F FF FE'
'7F 7F FF FF 7E 7F FF FF 71 FF FF FF 8F FF 28 00'
'00 00 10 00 00 00 20 00 00 00 01 00 04 00 00 00'
'00 00 80 00 00 00 00 00 00 00 00 00 00 00 10 00'
'00 00 00 00 00 00 3A 02 B1 00 0A 06 14 00 12 03'
'33 00 FF FF FF 00 12 12 12 00 0B 0B 0B 00 1B 1B'
'1B 00 25 02 6F 00 2E 02 92 00 1A 02 52 00 36 02'
'A6 00 15 03 3E 00 04 04 05 00 13 11 19 00 1E 02'
'62 00 2A 02 82 00 33 33 33 CC 43 33 33 33 33 33'
'CC 5C 33 33 33 33 33 36 C5 53 33 33 33 33 33 33'
'33 43 33 33 33 33 33 33 33 65 33 33 33 33 33 33'
'33 DC 33 33 33 33 33 33 33 17 EC 33 33 33 33 33'
'33 B0 07 53 33 33 33 33 33 90 00 B3 33 33 33 33'
'33 B0 00 FC 33 33 33 33 33 BA 00 A2 33 33 33 33'
'33 C7 88 82 33 33 33 33 33 3D D5 14 43 33 33 33'
'33 35 33 33 53 33 33 33 33 33 53 33 53 33 33 33'
'33 33 C5 5C 33 33 FC 7F 00 00 F0 FF 00 00 E1 FF'
'00 00 FD FF 00 00 FC FF 00 00 FC FF 00 00 FC 3F'
'00 00 FC 1F 00 00 FC 1F 00 00 FC 0F 00 00 FC 0F'
'00 00 FC 0F 00 00 FE 07 00 00 FE F7 00 00 FF 77'
'00 00 FF 0F 00 00'
} */
/*
* GUI resource definitions
*
* Copyright 2004 Ferenc Wagner
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
*
*/
#define IDI_WINE 1
#define IDD_STATUS 100
#define IDD_ABOUT 101
#define IDC_ST0 1000
#define IDC_PB0 1001
#define IDC_ST1 1002
#define IDC_PB1 1003
#define IDC_ST2 1004
#define IDC_PB2 1005
#define IDC_DIR 2000
#define IDC_OUT 2001
#define IDC_SB 3000
#define IDC_EDIT 4000
#define IDC_ABOUT 4001
......@@ -19,6 +19,7 @@
*/
#include <winsock.h>
#include <stdio.h>
#include <errno.h>
#include "winetest.h"
......@@ -29,6 +30,7 @@ open_http (const char *ipnum)
struct sockaddr_in sa;
SOCKET s;
report (R_STATUS, "Opening HTTP connection to %s", ipnum);
if (WSAStartup (MAKEWORD (2,2), &wsad)) return INVALID_SOCKET;
s = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
......@@ -68,15 +70,15 @@ send_buf (SOCKET s, const char *buf, size_t length)
}
int
send_str (SOCKET s, const char *fmt, ...)
send_str (SOCKET s, ...)
{
va_list ap;
char *p;
int ret;
size_t len;
va_start (ap, fmt);
p = vstrmake (&len, fmt, ap);
va_start (ap, s);
p = vstrmake (&len, ap);
va_end (ap);
if (!p) return 1;
ret = send_buf (s, p, len);
......@@ -111,55 +113,73 @@ send_file (const char *name)
s = open_http ("157.181.170.47");
if (s == INVALID_SOCKET) {
fprintf (stderr, "Can't open connection: %x.\n",
WSAGetLastError ());
report (R_WARNING, "Can't open network connection: %d",
WSAGetLastError ());
return 1;
}
f = fopen (name, "rb");
if (!f) goto abort1;
if (!f) {
report (R_WARNING, "Can't open file '%s': %d", name, errno);
goto abort1;
}
fseek (f, 0, SEEK_END);
filesize = ftell (f);
if (filesize > 1024*1024) goto abort2;
if (filesize > 1024*1024) {
report (R_WARNING,
"File too big (%d > 1 MB), copy and submit manually",
filesize);
goto abort2;
}
fseek (f, 0, SEEK_SET);
report (R_STATUS, "Sending header");
str = strmake (&total, body1, name);
ret = send_str (s, head, filesize + total + sizeof body2 - 1) ||
send_buf (s, str, total);
free (str);
if (ret) {
fprintf (stderr, "Can't send header.\n");
report (R_WARNING, "Error sending header: %d, %d",
errno, WSAGetLastError ());
goto abort2;
}
while ((bytes_read = fread (buffer, 1, sizeof buffer, f)))
report (R_STATUS, "Sending %u bytes of data", filesize);
report (R_PROGRESS, filesize);
while ((bytes_read = fread (buffer, 1, sizeof buffer / 8, f))) {
if (send_buf (s, buffer, bytes_read)) {
fprintf (stderr, "Can't send body.\n");
report (R_WARNING, "Error sending body: %d, %d",
errno, WSAGetLastError ());
goto abort2;
}
report (R_DELTA, bytes_read, "Network transfer: In progress");
}
fclose (f);
if (send_buf (s, body2, sizeof body2 - 1)) {
fprintf (stderr, "Can't send trailer.\n");
report (R_WARNING, "Error sending trailer: %d, %d",
errno, WSAGetLastError ());
goto abort2;
}
report (R_DELTA, 0, "Network transfer: Done");
total = 0;
while ((bytes_read = recv (s, buffer + total,
sizeof buffer - total, 0))) {
if ((signed)bytes_read == SOCKET_ERROR) {
fprintf (stderr, "Error receiving response: %d.\n",
WSAGetLastError ());
report (R_WARNING, "Error receiving reply: %d, %d",
errno, WSAGetLastError ());
goto abort1;
}
total += bytes_read;
if (total == sizeof buffer) {
fprintf (stderr, "Buffer overflow.\n");
report (R_WARNING, "Buffer overflow");
goto abort1;
}
}
if (close_http (s)) {
fprintf (stderr, "Error closing connection.\n");
report (R_WARNING, "Error closing connection: %d, %d",
errno, WSAGetLastError ());
return 1;
}
......
......@@ -22,22 +22,11 @@
#include "winetest.h"
void fatal (const char* msg)
{
MessageBox (NULL, msg, "Fatal Error", MB_ICONERROR | MB_OK);
exit (1);
}
void warning (const char* msg)
{
MessageBox (NULL, msg, "Warning", MB_ICONWARNING | MB_OK);
}
void *xmalloc (size_t len)
{
void *p = malloc (len);
if (!p) fatal ("Out of memory.");
if (!p) report (R_FATAL, "Out of memory.");
return p;
}
......@@ -45,7 +34,7 @@ void *xrealloc (void *op, size_t len)
{
void *p = realloc (op, len);
if (!p) fatal ("Out of memory.");
if (!p) report (R_FATAL, "Out of memory.");
return p;
}
......@@ -54,18 +43,20 @@ void xprintf (const char *fmt, ...)
va_list ap;
va_start (ap, fmt);
if (vprintf (fmt, ap) < 0) fatal ("Can't write logs.");
if (vprintf (fmt, ap) < 0) report (R_FATAL, "Can't write logs.");
va_end (ap);
}
char *vstrmake (size_t *lenp, const char *fmt, va_list ap)
char *vstrmake (size_t *lenp, va_list ap)
{
char *fmt;
size_t size = 1000;
char *p, *q;
int n;
p = malloc (size);
if (!p) return NULL;
fmt = va_arg (ap, char*);
while (1) {
n = vsnprintf (p, size, fmt, ap);
if (n < 0) size *= 2; /* Windows */
......@@ -82,14 +73,14 @@ char *vstrmake (size_t *lenp, const char *fmt, va_list ap)
return p;
}
char *strmake (size_t *lenp, const char *fmt, ...)
char *strmake (size_t *lenp, ...)
{
va_list ap;
char *p;
va_start (ap, fmt);
p = vstrmake (lenp, fmt, ap);
if (!p) fatal ("Out of memory.");
va_start (ap, lenp);
p = vstrmake (lenp, ap);
if (!p) report (R_FATAL, "Out of memory.");
va_end (ap);
return p;
}
......@@ -31,9 +31,27 @@ void warning (const char* msg);
void *xmalloc (size_t len);
void *xrealloc (void *op, size_t len);
void xprintf (const char *fmt, ...);
char *vstrmake (size_t *lenp, const char *fmt, va_list ap);
char *strmake (size_t *lenp, const char *fmt, ...);
char *vstrmake (size_t *lenp, va_list ap);
char *strmake (size_t *lenp, ...);
int send_file (const char *name);
/* GUI definitions */
#include <windows.h>
enum report_type {
R_STATUS = 0,
R_PROGRESS,
R_STEP,
R_DELTA,
R_DIR,
R_OUT,
R_FATAL,
R_WARNING,
R_ASK
};
int report (enum report_type t, ...);
#endif /* __WINETESTS_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment