wineconsole: Add usage message and more specific error messages.
This commit is contained in:
parent
18aafc27d0
commit
9d6761bd0c
|
@ -22,9 +22,11 @@
|
|||
#include "wine/port.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
#include "wine/server.h"
|
||||
#include "winecon_private.h"
|
||||
#include "winnls.h"
|
||||
#include "winuser.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
|
||||
|
@ -36,6 +38,27 @@ void WINECON_Fatal(const char* msg)
|
|||
ExitProcess(0);
|
||||
}
|
||||
|
||||
static void printf_res(UINT uResId, ...)
|
||||
{
|
||||
WCHAR buffer[1024];
|
||||
CHAR ansi[1024];
|
||||
va_list args;
|
||||
|
||||
va_start(args, uResId);
|
||||
LoadStringW(GetModuleHandle(NULL), uResId, buffer, sizeof(buffer)/sizeof(WCHAR));
|
||||
WideCharToMultiByte(CP_UNIXCP, 0, buffer, -1, ansi, sizeof(ansi), NULL, NULL);
|
||||
vprintf(ansi, args);
|
||||
va_end(args);
|
||||
}
|
||||
|
||||
static void WINECON_Usage()
|
||||
{
|
||||
printf_res(IDS_USAGE_HEADER);
|
||||
printf_res(IDS_USAGE_BACKEND);
|
||||
printf_res(IDS_USAGE_COMMAND);
|
||||
printf_res(IDS_USAGE_FOOTER);
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
* WINECON_FetchCells
|
||||
*
|
||||
|
@ -729,12 +752,16 @@ struct wc_init {
|
|||
HANDLE event;
|
||||
};
|
||||
|
||||
#define WINECON_CMD_SHOW_USAGE 0x10000
|
||||
|
||||
/******************************************************************
|
||||
* WINECON_ParseOptions
|
||||
*
|
||||
*
|
||||
* RETURNS
|
||||
* On success: 0
|
||||
* On error: error string id optionaly with the CMD_SHOW_USAGE flag
|
||||
*/
|
||||
static BOOL WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci)
|
||||
static UINT WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci)
|
||||
{
|
||||
memset(wci, 0, sizeof(*wci));
|
||||
wci->ptr = lpCmdLine;
|
||||
|
@ -749,7 +776,7 @@ static BOOL WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci)
|
|||
{
|
||||
char* end;
|
||||
wci->event = (HANDLE)strtol(wci->ptr + 12, &end, 10);
|
||||
if (end == wci->ptr + 12) return FALSE;
|
||||
if (end == wci->ptr + 12) return IDS_CMD_INVALID_EVENT_ID;
|
||||
wci->mode = from_event;
|
||||
wci->ptr = end;
|
||||
wci->backend = WCUSER_InitBackend;
|
||||
|
@ -766,13 +793,20 @@ static BOOL WINECON_ParseOptions(const char* lpCmdLine, struct wc_init* wci)
|
|||
wci->ptr += 16;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return IDS_CMD_INVALID_BACKEND;
|
||||
}
|
||||
else
|
||||
return FALSE;
|
||||
return IDS_CMD_INVALID_OPTION|WINECON_CMD_SHOW_USAGE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
if (wci->mode == from_event)
|
||||
return 0;
|
||||
|
||||
while (*wci->ptr == ' ' || *wci->ptr == '\t') wci->ptr++;
|
||||
if (*wci->ptr == 0)
|
||||
return IDS_CMD_ABOUT|WINECON_CMD_SHOW_USAGE;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
@ -790,9 +824,11 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
|||
int ret = 1;
|
||||
struct wc_init wci;
|
||||
|
||||
if (!WINECON_ParseOptions(lpCmdLine, &wci))
|
||||
if ((ret = WINECON_ParseOptions(lpCmdLine, &wci)) != 0)
|
||||
{
|
||||
WINE_ERR("Wrong command line options\n");
|
||||
printf_res(ret & 0xffff);
|
||||
if (ret & WINECON_CMD_SHOW_USAGE)
|
||||
WINECON_Usage();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -814,7 +850,11 @@ int PASCAL WinMain(HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmdLine, INT nCmdSh
|
|||
return 0;
|
||||
ret = WINECON_Spawn(data, buffer);
|
||||
if (!ret)
|
||||
WINE_MESSAGE("wineconsole: spawning client program failed (%s), invalid/missing command line arguments ?\n", wine_dbgstr_w(buffer));
|
||||
{
|
||||
WINECON_Delete(data);
|
||||
printf_res(IDS_CMD_LAUNCH_FAILED, wine_dbgstr_a(wci.ptr));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -36,6 +36,20 @@ IDS_DLG_TIT_DEFAULT, "Setup - Default settings"
|
|||
IDS_DLG_TIT_CURRENT, "Setup - Current settings"
|
||||
IDS_DLG_TIT_ERROR, "Configuration error"
|
||||
IDS_DLG_ERR_SBWINSIZE, "Screen buffer size must be greater or equal to the window's one"
|
||||
|
||||
IDS_CMD_INVALID_EVENT_ID "wineconsole: Couldn't parse event id\n"
|
||||
IDS_CMD_INVALID_BACKEND "wineconsole: Invalid backend\n"
|
||||
IDS_CMD_INVALID_OPTION "wineconsole: Unrecognized command line option\n"
|
||||
IDS_CMD_ABOUT "Starts a program in a Wine console\n"
|
||||
IDS_CMD_LAUNCH_FAILED "wineconsole: Starting program %s failed.\n"\
|
||||
"The command is invalid.\n"
|
||||
|
||||
IDS_USAGE_HEADER "\nUsage:\n wineconsole [options] <command>\n\nOptions:\n"
|
||||
IDS_USAGE_BACKEND " --backend={user|ncurses} Choosing user will spawn a new window, ncurses will\n"\
|
||||
" try to setup the current terminal as a Wine console\n"
|
||||
IDS_USAGE_COMMAND " <command> The Wine program to launch in the console\n"
|
||||
IDS_USAGE_FOOTER "\nExample:\n wineconsole cmd\nStarts the Wine command prompt in a Wine console\n\n"
|
||||
|
||||
END
|
||||
|
||||
IDD_OPTION DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105
|
||||
|
|
|
@ -37,6 +37,20 @@ IDS_DLG_TIT_DEFAULT, "Setup - Domy
|
|||
IDS_DLG_TIT_CURRENT, "Setup - Wybrane ustawienia"
|
||||
IDS_DLG_TIT_ERROR, "B³¹d konfiguracji"
|
||||
IDS_DLG_ERR_SBWINSIZE, "Wielkoœæ bufora ekranu musi byæ wiêksza ni¿ wielkoœæ bufora okna."
|
||||
|
||||
IDS_CMD_INVALID_EVENT_ID "wineconsole: Zły format 'event id'\n"
|
||||
IDS_CMD_INVALID_BACKEND "wineconsole: Niewłaściwa wartość opcji 'backend'\n"
|
||||
IDS_CMD_INVALID_OPTION "wineconsole: Nieznana opcja na linii poleceń\n"
|
||||
IDS_CMD_ABOUT "Uruchamia program w konsoli Wine\n"
|
||||
IDS_CMD_LAUNCH_FAILED "wineconsole: Nie udało się uruchomić programu %s.\n"\
|
||||
"Polecenie jest niewłaściwe.\n"
|
||||
|
||||
IDS_USAGE_HEADER "\nUżycie:\n wineconsole [opcje] <polecenie>\n\nOpcje:\n"
|
||||
IDS_USAGE_BACKEND " --backend={user|ncurses} Wybór 'user' spowoduje wyświetlenie nowego okna, 'ncurses'\n"\
|
||||
" spróbuje przerobić aktualnie używany terminal na konsolę Wine\n"
|
||||
IDS_USAGE_COMMAND " <command> Program Wine który należy uruchomić\n"
|
||||
IDS_USAGE_FOOTER "\nPrzykład:\n wineconsole cmd\nUruchamia wiersz poleceń Wine w konsoli Wine\n\n"
|
||||
|
||||
END
|
||||
|
||||
IDD_OPTION DIALOG LOADONCALL MOVEABLE DISCARDABLE 36, 24, 140, 105
|
||||
|
|
|
@ -40,6 +40,17 @@
|
|||
#define IDS_FNT_PREVIEW_1 0x201
|
||||
#define IDS_FNT_PREVIEW_2 0x202
|
||||
|
||||
#define IDS_CMD_INVALID_EVENT_ID 0x300
|
||||
#define IDS_CMD_INVALID_BACKEND 0x301
|
||||
#define IDS_CMD_INVALID_OPTION 0x302
|
||||
#define IDS_CMD_ABOUT 0x303
|
||||
#define IDS_CMD_LAUNCH_FAILED 0x304
|
||||
|
||||
#define IDS_USAGE_HEADER 0x310
|
||||
#define IDS_USAGE_BACKEND 0x311
|
||||
#define IDS_USAGE_COMMAND 0x312
|
||||
#define IDS_USAGE_FOOTER 0x313
|
||||
|
||||
/* dialog boxes */
|
||||
#define IDD_OPTION 0x0100
|
||||
#define IDD_FONT 0x0200
|
||||
|
|
Loading…
Reference in New Issue