Author: mladen.turk(a)jboss.com
Date: 2008-04-04 12:17:51 -0400 (Fri, 04 Apr 2008)
New Revision: 1519
Added:
trunk/build/install/xtool/commonc.manifest
Modified:
trunk/build/install/xtool/NMAKEmakefile
trunk/build/install/xtool/xtool.c
trunk/build/install/xtool/xtool.rc
Log:
Add html page display tool
Modified: trunk/build/install/xtool/NMAKEmakefile
===================================================================
--- trunk/build/install/xtool/NMAKEmakefile 2008-04-04 06:18:32 UTC (rev 1518)
+++ trunk/build/install/xtool/NMAKEmakefile 2008-04-04 16:17:51 UTC (rev 1519)
@@ -30,8 +30,11 @@
!ENDIF
LFLAGS = $(LFLAGS) /version:1.0
-LFLAGS = $(LFLAGS) user32.lib shell32.lib advapi32.lib psapi.lib imagehlp.lib
version.lib
+LFLAGS = $(LFLAGS) user32.lib gdi32.lib winspool.lib comdlg32.lib comctl32.lib
+LFLAGS = $(LFLAGS) shlwapi.lib netapi32.lib shell32.lib ole32.lib urlmon.lib
+LFLAGS = $(LFLAGS) oleaut32.lib psapi.lib version.lib advapi32.lib imagehlp.lib
+
PDBFLAGS = -Fo$(WORKDIR)\ -Fd$(WORKDIR)\$(PROJECT)-src
OBJECTS = \
$(WORKDIR)\xtool.obj
Added: trunk/build/install/xtool/commonc.manifest
===================================================================
--- trunk/build/install/xtool/commonc.manifest (rev 0)
+++ trunk/build/install/xtool/commonc.manifest 2008-04-04 16:17:51 UTC (rev 1519)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"
standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1"
manifestVersion="1.0">
+<assemblyIdentity version="3.1.0.0" processorArchitecture="*"
name="JBoss Installer" type="win32" />
+<description>JBoss Windows Installer</description>
+<dependency>
+<dependentAssembly>
+<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
processorArchitecture="*" publicKeyToken="6595b64144ccf1df"
language="*" />
+</dependentAssembly>
+</dependency>
+</assembly>
Property changes on: trunk/build/install/xtool/commonc.manifest
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: trunk/build/install/xtool/xtool.c
===================================================================
--- trunk/build/install/xtool/xtool.c 2008-04-04 06:18:32 UTC (rev 1518)
+++ trunk/build/install/xtool/xtool.c 2008-04-04 16:17:51 UTC (rev 1519)
@@ -54,10 +54,20 @@
#define _WIN32_WINNT 0x0500
#endif
#include <windows.h>
+#include <windowsx.h>
+#include <commdlg.h>
+#include <commctrl.h>
+#include <objbase.h>
+#include <shlobj.h>
+#include <shlwapi.h>
#include <shellapi.h>
+#include <zmouse.h>
+#include <richedit.h>
#include <psapi.h>
-#include <shlobj.h>
#include <imagehlp.h>
+#include <urlmon.h>
+#include <mshtmhst.h>
+#include <lm.h>
#include <stdio.h>
#include <stdlib.h>
@@ -92,7 +102,16 @@
/* This is used to cache lengths in x_strvcat */
#define MAX_SAVED_LENGTHS 8
+/* Resource definitions from .rc file */
+#define IDI_MAINICON 101
+#define IDI_RHELICON 102
+#define DEF_WWIDTH 505
+#define DEF_WHEIGHT 360
+#define SIZ_BUFLEN 1024
+#define SIZ_BUFMAX (SIZ_BUFLEN - 1)
+#define IS_INVALID_HANDLE(x) (((x) == NULL || (x) == INVALID_HANDLE_VALUE))
+
/*
* Alignment macros
*/
@@ -157,7 +176,7 @@
static int xtools_pause = 0;
static SYSTEM_INFO win_osinf;
static OSVERSIONINFOEXA win_osver;
-static int verbose = 0;
+static int xtrace = 0;
static int xquiet = 0;
/*
@@ -1525,7 +1544,7 @@
DWORD el = ExpandEnvironmentStringsW(ibuf, ebuf,
INFO_BUFFER_SIZE);
if (el > INFO_BUFFER_SIZE) {
- if (verbose)
+ if (xtrace)
warnx("expansion string to large %d", el);
}
else if (el) {
@@ -1693,7 +1712,7 @@
if (!CreateDirectoryW(path, NULL)) {
r = x_cerror(GetLastError());
if (r == EEXIST) {
- if (verbose)
+ if (xtrace)
warnx("cannot create directory '%S': %s",
path, cstrerror(EEXIST));
return EEXIST;
@@ -1702,14 +1721,14 @@
return ENOENT;
}
else {
- if (verbose)
+ if (xtrace)
warnx("cannot create directory '%S': %s",
path, cstrerror(r));
return r;
}
}
else {
- if (verbose)
+ if (xtrace > 1)
warnx("created directory '%S'", path);
return 0;
}
@@ -1769,7 +1788,7 @@
}
if (!RemoveDirectoryW(path))
r = x_cerror(GetLastError());
- if (verbose) {
+ if (xtrace) {
if (r)
warnx("cannot remove directory '%S': %s",
path, cstrerror(r));
@@ -1811,7 +1830,7 @@
if (!RemoveDirectoryW(path))
r = x_cerror(GetLastError());
}
- if (verbose) {
+ if (xtrace) {
if (r)
warnx("cannot remove directory '%s': %s",
loc, cstrerror(r));
@@ -1843,7 +1862,7 @@
FOF_SILENT;
r = x_cerror(SHFileOperationW(&op));
- if (verbose) {
+ if (xtrace) {
if (r)
warnx("cannot remove file '%s': %s",
loc, cstrerror(r));
@@ -1861,11 +1880,11 @@
wchar_t path[X_MAX_PATH];
int r = 0;
- if (r = x_wfullpath(path, X_MAX_PATH, src))
+ if ((r = x_wfullpath(path, X_MAX_PATH, src)))
return r;
if (!GetFileAttributesExW(path, GetFileExInfoStandard, pa)) {
r = x_cerror(GetLastError());
- if (verbose && r != ENOENT) {
+ if (xtrace && r != ENOENT) {
warnx("cannot stat file '%S': %s",
path, cstrerror(errno));
}
@@ -1873,6 +1892,27 @@
return r;
}
+static int x_fattrib(const char *src)
+{
+
+ WIN32_FILE_ATTRIBUTE_DATA pa;
+ wchar_t path[X_MAX_PATH];
+ int r = 0;
+
+ if ((errno = x_wfullpath(path, X_MAX_PATH, src))) {
+ return 0;
+ }
+ if (!GetFileAttributesExW(path, GetFileExInfoStandard, &pa)) {
+ errno = x_cerror(GetLastError());
+ return 0;
+ }
+ if (pa.dwFileAttributes)
+ return (int)pa.dwFileAttributes;
+ else
+ return FILE_ATTRIBUTE_ARCHIVE;
+}
+
+
/*
* ---------------------------------------------------------------------
* end of file functions
@@ -1950,7 +1990,7 @@
int nextline = 0;
if (!(fp = x_fopen(fname, "rt"))) {
- if (verbose)
+ if (xtrace)
warnx("'%s' %s", fname, cstrerror(errno));
return NULL;
}
@@ -1982,7 +2022,7 @@
if (*line == '[') {
char *ends = strchr(++line, ']');
if (!ends) {
- if (verbose)
+ if (xtrace)
warnx("'%s' unterminated section at line %d",
fname, counter);
goto cleanup;
@@ -1994,7 +2034,7 @@
ini->name = x_strdup(section);
}
else {
- if (verbose > 1)
+ if (xtrace > 1)
warnx("'%s' duplicate section at line %d",
fname, counter);
}
@@ -2018,7 +2058,7 @@
line = rltrim(line);
if (!*line) {
/* Skip entries without keys **/
- if (verbose > 1)
+ if (xtrace > 1)
warnx("'%s' missing key at line %d",
fname, counter);
nextline = 0;
@@ -2217,6 +2257,495 @@
/*
* ---------------------------------------------------------------------
+ * begin of WIndows GUI
+ * ---------------------------------------------------------------------
+ */
+
+#define MGUI_WINDOWS 32
+
+HICON gui_h16Icon = NULL;
+HICON gui_h32Icon = NULL;
+HICON gui_h48Icon = NULL;
+HMODULE gui_hMSHTML = NULL;
+HWND gui_DialogWnd = NULL;
+static HINSTANCE gui_hInstance = NULL;
+static HWND gui_hMainWnd = NULL;
+static HMODULE gui_hRichedit = NULL;
+
+static UINT gui_ucNumLines = 3;
+static CHAR gui_szWndClass[MAX_PATH];
+
+
+static HWND gui_Windows[MGUI_WINDOWS];
+
+static int
+GuiRegisterWindow(HWND hWnd)
+{
+ int i;
+ for (i = 0; i < MGUI_WINDOWS; i++) {
+ if (!gui_Windows[i]) {
+ gui_Windows[i] = hWnd;
+ return i;
+ }
+ }
+ return -1;
+}
+
+static void
+GuiUnregisterWindow(int nIndex)
+{
+ if (nIndex >= 0 && nIndex < MGUI_WINDOWS)
+ gui_Windows[nIndex] = NULL;
+}
+
+static BOOL
+GuiInitialize()
+{
+ int i;
+ INITCOMMONCONTROLSEX stCmn;
+
+ CoInitializeEx(NULL, COINIT_APARTMENTTHREADED);
+ gui_hInstance = GetModuleHandle(NULL);
+ stCmn.dwSize = sizeof(INITCOMMONCONTROLSEX);
+ stCmn.dwICC = ICC_WIN95_CLASSES | ICC_USEREX_CLASSES |
+ ICC_COOL_CLASSES | ICC_NATIVEFNTCTL_CLASS |
+ ICC_INTERNET_CLASSES | ICC_PAGESCROLLER_CLASS |
+ ICC_BAR_CLASSES;
+
+ InitCommonControlsEx(&stCmn);
+ gui_hRichedit = LoadLibraryA("RICHED32.DLL");
+ gui_hMSHTML = LoadLibraryA("MSHTML.DLL");
+
+ gui_h16Icon = LoadImage(gui_hInstance, MAKEINTRESOURCE(IDI_MAINICON),
+ IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);
+ gui_h32Icon = LoadImage(gui_hInstance, MAKEINTRESOURCE(IDI_MAINICON),
+ IMAGE_ICON, 32, 32, LR_DEFAULTCOLOR);
+ gui_h48Icon = LoadImage(gui_hInstance, MAKEINTRESOURCE(IDI_RHELICON),
+ IMAGE_ICON, 48, 48, LR_DEFAULTCOLOR);
+
+ SystemParametersInfo(SPI_GETWHEELSCROLLLINES, 0,
+ &gui_ucNumLines, 0);
+ for (i = 0; i < MGUI_WINDOWS; i++)
+ gui_Windows[i] = NULL;
+ return TRUE;
+}
+
+static BOOL
+GuiTerminate()
+{
+ int i;
+ for (i = 0; i < MGUI_WINDOWS; i++) {
+ if (gui_Windows[i]) {
+ SendMessage(gui_Windows[i], WM_CLOSE, 0, 0);
+ gui_Windows[i] = NULL;
+ }
+ }
+ FreeLibrary(gui_hRichedit);
+ FreeLibrary(gui_hMSHTML);
+
+ return TRUE;
+}
+
+/**
+ * Load the resource string with the ID given, and return a
+ * pointer to it. Notice that the buffer is common memory so
+ * the string must be used before this call is made a second time.
+ */
+static LPSTR
+GuiLoadResource(
+ UINT wID,
+ UINT nBuf)
+{
+ static CHAR szBuf[4][SIZ_BUFLEN];
+ if (nBuf > 3)
+ return "";
+ if (LoadStringA(gui_hInstance, wID, szBuf[nBuf], SIZ_BUFMAX) > 0)
+ return szBuf[nBuf];
+ else
+ return "";
+}
+
+static void
+GuiCenterWindow(HWND hWnd)
+{
+ RECT rc, rw;
+ int cw, ch;
+ int px, py;
+
+ /* Get the Height and Width of the child window */
+ GetWindowRect(hWnd, &rc);
+ cw = rc.right - rc.left;
+ ch = rc.bottom - rc.top;
+
+ /* Get the limits of the 'workarea' */
+ if (!SystemParametersInfo(SPI_GETWORKAREA,
+ sizeof(RECT),
+ &rw,
+ 0)) {
+ rw.left = rw.top = 0;
+ rw.right = GetSystemMetrics(SM_CXSCREEN);
+ rw.bottom = GetSystemMetrics(SM_CYSCREEN);
+ }
+
+ /* Calculate new X and Y position*/
+ px = (rw.right - cw) / 2;
+ py = (rw.bottom - ch) / 2;
+ SetWindowPos(hWnd, HWND_TOP, px, py, 0, 0,
+ SWP_NOSIZE | SWP_SHOWWINDOW);
+}
+
+static BOOL
+GuiBrowseForFolder(
+ HWND hWnd,
+ LPCSTR szTitle,
+ LPSTR szPath)
+{
+ BOOL rv = FALSE;
+
+ BROWSEINFO bi;
+ ITEMIDLIST *il , *ir;
+ LPMALLOC pMalloc;
+
+ memset(&bi, 0, sizeof(BROWSEINFO));
+ SHGetSpecialFolderLocation(hWnd, CSIDL_DRIVES, &il);
+
+ bi.lpszTitle = szTitle;
+ bi.pszDisplayName = szPath;
+ bi.hwndOwner = hWnd;
+ bi.ulFlags = BIF_USENEWUI;
+ bi.pidlRoot = il;
+
+ if ((ir = SHBrowseForFolder(&bi)) != NULL) {
+ SHGetPathFromIDList(ir, szPath);
+ rv = TRUE;
+ }
+ if (SHGetMalloc(&pMalloc)) {
+ pMalloc->lpVtbl->Free(pMalloc, il);
+ pMalloc->lpVtbl->Release(pMalloc);
+ }
+ return rv;
+}
+
+#define HBUF_SIZE 8192
+#define MBUF_SIZE 4096
+
+static SHOWHTMLDIALOGEXFN *pfnShowHTMLDialog = NULL;
+
+typedef struct {
+ IMoniker *lpImk;
+ CHAR szReturnVal[HBUF_SIZE];
+} MC_HTML_DIALOG, *LPMC_HTML_DIALOG;
+
+typedef struct DHTML_THREAD_PARAMS {
+ BOOL bDone;
+ HWND hParent;
+ LPMC_HTML_DIALOG hHtmlDlg;
+ WCHAR szOptions[1024];
+ WCHAR szArguments[MBUF_SIZE];
+} DHTML_THREAD_PARAMS;
+
+static LPWSTR
+AnsiToWide(
+ LPCSTR szAnsi,
+ LPWSTR szWide,
+ DWORD dwLength)
+{
+
+ if (!szWide) {
+ dwLength = MultiByteToWideChar(CP_ACP, 0, szAnsi, -1, NULL, 0);
+ if (dwLength == 0)
+ return NULL;
+ if (!(szWide = (LPWSTR)calloc(sizeof(WCHAR), (dwLength + 1))))
+ return NULL;
+ }
+ if (MultiByteToWideChar(CP_ACP, 0, szAnsi, -1,
+ szWide, dwLength))
+ return szWide;
+ else
+ return NULL;
+}
+
+static LPSTR
+WideToAnsi(
+ LPCWSTR szWide,
+ LPSTR szAnsi,
+ DWORD dwLength)
+{
+ if (!szAnsi) {
+ dwLength = WideCharToMultiByte(CP_ACP, 0, szWide, -1,
+ NULL, 0, NULL, NULL);
+ if (dwLength == 0)
+ return NULL;
+ if (!(szAnsi = (LPSTR)calloc(sizeof(CHAR), (dwLength + 1))))
+ return NULL;
+ }
+
+ if (WideCharToMultiByte(CP_ACP, 0, szWide, -1,
+ szAnsi, dwLength, NULL, NULL))
+ return szAnsi;
+ else
+ return NULL;
+
+}
+
+static HANDLE
+DHTMLDialogInit(
+ HINSTANCE hResInstance,
+ LPCSTR szHtml)
+{
+ LPMC_HTML_DIALOG hDlg;
+ OLECHAR bstr[MAX_PATH];
+
+ hDlg = (LPMC_HTML_DIALOG)calloc(1, sizeof(MC_HTML_DIALOG));
+
+ if (!hDlg)
+ return INVALID_HANDLE_VALUE;
+
+ if (!gui_hMSHTML)
+ goto cleanup;
+ if (!pfnShowHTMLDialog)
+ pfnShowHTMLDialog = (SHOWHTMLDIALOGEXFN*)GetProcAddress(
+ gui_hMSHTML,
+ "ShowHTMLDialogEx");
+ if (!pfnShowHTMLDialog)
+ goto cleanup;
+
+ if (hResInstance) {
+ CHAR szTemp[MAX_PATH];
+ strcpy(szTemp, "res://");
+ GetModuleFileNameA(hResInstance, szTemp + strlen(szTemp),
+ ARRAYSIZE(szTemp) - strlen(szTemp));
+ if (*szHtml != '/')
+ strcat(szTemp, "/");
+ strcat(szTemp, szHtml);
+ AnsiToWide(szTemp, bstr, ARRAYSIZE(bstr));
+ }
+ else
+ AnsiToWide(szHtml, bstr, ARRAYSIZE(bstr));
+ CreateURLMoniker(NULL, bstr, &hDlg->lpImk);
+
+ if (!hDlg->lpImk)
+ goto cleanup;
+ return hDlg;
+cleanup:
+
+ free(hDlg);
+ return INVALID_HANDLE_VALUE;
+}
+
+static void
+DHTMLDialogClose(
+ HANDLE hHtmlDlg)
+{
+
+ LPMC_HTML_DIALOG hDlg = (LPMC_HTML_DIALOG)hHtmlDlg;
+ if (IS_INVALID_HANDLE(hHtmlDlg))
+ return;
+ hDlg->lpImk->lpVtbl->Release(hDlg->lpImk);
+ free(hDlg);
+}
+
+static DWORD WINAPI
+dhtmlRunThread(LPVOID lpParam)
+{
+ DWORD rv = ERROR_SUCCESS;
+ HRESULT hr;
+ VARIANT varArgs, varReturn;
+ DHTML_THREAD_PARAMS *pD = (DHTML_THREAD_PARAMS *)lpParam;
+ LPMC_HTML_DIALOG hDlg = pD->hHtmlDlg;
+
+ if (IS_INVALID_HANDLE(pD->hHtmlDlg)) {
+ rv = ERROR_INVALID_HANDLE;
+ goto cleanup;
+ }
+ VariantInit(&varReturn);
+ varArgs.vt = VT_BSTR;
+ varArgs.bstrVal = SysAllocString(pD->szArguments);
+ hr = (*pfnShowHTMLDialog)(pD->hParent,
+ hDlg->lpImk,
+ HTMLDLG_MODAL | HTMLDLG_VERIFY,
+ &varArgs,
+ pD->szOptions,
+ &varReturn);
+ VariantClear(&varArgs);
+ if (SUCCEEDED(hr)) {
+ switch(varReturn.vt) {
+ case VT_BSTR:
+ WideToAnsi(varReturn.bstrVal, hDlg->szReturnVal, HBUF_SIZE);
+ break;
+ }
+ VariantClear(&varReturn);
+ rv = ERROR_SUCCESS;
+ }
+ else
+ rv = GetLastError();
+cleanup:
+ pD->bDone = TRUE;
+ ExitThread(rv);
+ return rv;
+}
+
+static BOOL
+DHTMLDialogRun(
+ HWND hParent,
+ HANDLE hHtmlDlg,
+ LPCSTR szTitle,
+ DWORD dwWidth,
+ DWORD dwHeight,
+ DWORD dwFlags,
+ DWORD dwTimeout,
+ LPCSTR szArguments)
+{
+ DWORD dwThreadId;
+ HANDLE hThread;
+ HWND hWnd = NULL;
+ DWORD i;
+ BOOL rv = FALSE;
+ DHTML_THREAD_PARAMS pD;
+ int w = -1;
+
+ if (IS_INVALID_HANDLE(hHtmlDlg))
+ return FALSE;
+ pD.hParent = hParent;
+ pD.hHtmlDlg = hHtmlDlg;
+ swprintf(pD.szOptions,
+ L"scroll: no; status: no; help: no; dialogHeight: %dpx; dialogWidth:
%dpx",
+ dwHeight, dwWidth);
+ if (dwFlags == 1)
+ wcscat(pD.szOptions, L"; unadorned:yes");
+ if (szArguments)
+ AnsiToWide(szArguments, pD.szArguments,
+ ARRAYSIZE(pD.szArguments));
+
+ hThread = CreateThread(NULL,
+ 0,
+ dhtmlRunThread,
+ &pD,
+ 0,
+ &dwThreadId);
+ if (IS_INVALID_HANDLE(hThread))
+ return FALSE;
+
+ /* Hack to change the Icon of HTML Dialog */
+ for (i = 0; i < 1000; i++) {
+ if ((hWnd = FindWindowEx(hParent, NULL, NULL, szTitle))) {
+ w = GuiRegisterWindow(hWnd);
+ SetClassLong(hWnd, GCL_HICONSM, (LONG)gui_h16Icon);
+ break;
+ }
+ if (pD.bDone)
+ break;
+ Sleep(1);
+ }
+ if ((i = WaitForSingleObject(hThread, dwTimeout)) == WAIT_TIMEOUT) {
+ if (hWnd) {
+ SendMessage(hWnd, WM_CLOSE, 0, 0);
+ WaitForSingleObject(hThread, INFINITE);
+ }
+ }
+ if (GetExitCodeThread(hThread, &i) && i == 0) {
+ rv = TRUE;
+ }
+ CloseHandle(hThread);
+ GuiUnregisterWindow(w);
+ return rv;
+}
+
+LPSTR
+DHTMLDialogResult(
+ HANDLE hHtmlDlg)
+{
+
+ LPMC_HTML_DIALOG hDlg = (LPMC_HTML_DIALOG)hHtmlDlg;
+ if (IS_INVALID_HANDLE(hHtmlDlg))
+ return NULL;
+
+ return hDlg->szReturnVal;
+}
+
+static LPSTR
+GetHtmlPath(
+ LPCSTR szWorkDir,
+ LPCSTR szHtmlPage)
+{
+
+ LPSTR p;
+ LPSTR pHtml = (LPSTR)x_malloc(MAX_PATH);
+
+ strcpy(pHtml, "file://");
+ if (szWorkDir) {
+ strcpy(pHtml, szWorkDir);
+ if (*szHtmlPage != '/')
+ strcat(pHtml, "/");
+ }
+ strcat(pHtml, szHtmlPage);
+ for (p = pHtml; *p; p++) {
+ if (*p == '\\')
+ *p = '/';
+ }
+ return pHtml;
+}
+
+static BOOL
+RunCustomPage(
+ LPCSTR szHtmlPage,
+ LPCSTR szHtmlTitle,
+ LPCSTR szHtmlParams,
+ DWORD dwHtmlWidth,
+ DWORD dwHtmlHeight,
+ DWORD dwTimeout,
+ DWORD dwFlags,
+ LPCSTR szFile)
+{
+ HANDLE hHtml;
+ LPSTR szUrl;
+ LPSTR retVal;
+ BOOL rv = FALSE;
+ FILE *fp;
+
+ szUrl = GetHtmlPath(NULL, szHtmlPage);
+ hHtml = DHTMLDialogInit(NULL, szUrl);
+ if (IS_INVALID_HANDLE(hHtml)) {
+ x_free(szUrl);
+ return FALSE;
+ }
+ DHTMLDialogRun(NULL, hHtml,
+ szHtmlTitle,
+ dwHtmlWidth,
+ dwHtmlHeight,
+ dwFlags,
+ dwTimeout,
+ szHtmlParams);
+ retVal = DHTMLDialogResult(hHtml);
+ if (szFile)
+ fp = fopen(szFile, "w");
+ else
+ fp = stdout;
+ if (fp) {
+ if (retVal && *retVal) {
+ if (!strncmp(retVal, "OK", 2))
+ rv = TRUE;
+ fputs(retVal, fp);
+ }
+ else
+ fputs("NULL", fp);
+ fflush(fp);
+ if (fp != stdout)
+ fclose(fp);
+ }
+ x_free(szUrl);
+ DHTMLDialogClose(hHtml);
+ return rv;
+}
+
+/*
+ * ---------------------------------------------------------------------
+ * end of WIndows GUI
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * ---------------------------------------------------------------------
* begin of tests
* ---------------------------------------------------------------------
*/
@@ -2331,6 +2860,7 @@
fprintf(stderr, " -q Be quiet.\n");
fprintf(stderr, " -v --verbose Explain what is being done.\n");
fprintf(stderr, " --version Output version information and
exit.\n");
+ fprintf(stderr, " -V Explain what is being done in
detail.\n");
fprintf(stderr, " -h --help Display this help and exit.\n\n");
}
@@ -2427,6 +2957,18 @@
return retval;
}
+static int prog_html_usage(int retval)
+{
+ fprintf(stderr, "Usage: %s [OPTION]... FILE\n", progname);
+ fprintf(stderr, "Update the access and modification times of each FILE to the
current time\n\n");
+ fprintf(stderr, " -g STRING Geometry in format
'widthXheight'.\n");
+ fprintf(stderr, " -n STRING Page title. If not present defaults to html
<title> tag.\n");
+ fprintf(stderr, " -t NUMBER Splash page with NUMBER of miliseconds
delay.\n\n");
+ fprintf(stderr, " -T NUMBER Splash page with NUMBER of seconds
delay.\n\n");
+ print_stdusage();
+ return retval;
+}
+
/*
* ---------------------------------------------------------------------
* end of programs usage
@@ -2443,13 +2985,11 @@
{
int i, ch, rv = 0;
- verbose = 0;
-
- while ((ch = getopt(argc, argv, "hqv", 1)) != EOF) {
+ while ((ch = getopt(argc, argv, "hqvV", 1)) != EOF) {
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -2458,10 +2998,13 @@
return prog_mkdir_usage(EINVAL);
break;
case 'v':
- verbose = 1;
+ xtrace = 1;
break;
+ case 'V':
+ xtrace = 9;
+ break;
case 'q':
- xquiet = 1;
+ xquiet = 1;
break;
case 'h':
return prog_mkdir_usage(0);
@@ -2490,11 +3033,11 @@
int i, ch, rv = 0;
int recurse = 0;
- while ((ch = getopt(argc, argv, "rhqv", 1)) != EOF) {
+ while ((ch = getopt(argc, argv, "rhqvV", 1)) != EOF) {
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -2503,8 +3046,11 @@
return prog_rmdir_usage(EINVAL);
break;
case 'v':
- verbose = 1;
+ xtrace = 1;
break;
+ case 'V':
+ xtrace = 9;
+ break;
case 'q':
xquiet = 1;
break;
@@ -2549,11 +3095,11 @@
wchar_t file[X_MAX_PATH];
WIN32_FILE_ATTRIBUTE_DATA ad;
- while ((ch = getopt(argc, argv, "acfmr:t:hqv", 1)) != EOF) {
+ while ((ch = getopt(argc, argv, "acfmr:t:hqvV", 1)) != EOF) {
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -2562,10 +3108,13 @@
return prog_touch_usage(EINVAL);
break;
case 'v':
- verbose = 1;
+ xtrace = 1;
break;
+ case 'V':
+ xtrace = 9;
+ break;
case 'q':
- xquiet = 1;
+ xquiet = 1;
break;
case 'h':
return prog_touch_usage(0);
@@ -2602,7 +3151,7 @@
flags = 3;
if (from) {
if (rv = x_fstat(&ad, from)) {
- if (verbose) {
+ if (xtrace) {
x_wfullpath(file, X_MAX_PATH, from);
warnx("'%S' -- %s", file, cstrerror(rv));
}
@@ -2632,7 +3181,7 @@
&t.wDay, &t.wHour, &t.wMinute);
else {
- if (verbose)
+ if (xtrace)
warnx("invalid time format %s", tstr);
return EINVAL;
}
@@ -2647,7 +3196,7 @@
t.wYear = n.wYear;
}
if (!SystemTimeToFileTime(&t, &ad.ftLastAccessTime)) {
- if (verbose)
+ if (xtrace)
warnx("invalid time format %04d-%02d-%02d-%02d-%02d.%02d",
t.wYear, t.wMonth, t.wDay, t.wHour,
t.wMinute, t.wSecond);
@@ -2662,7 +3211,7 @@
for (i = 0; i < argc; i++) {
HANDLE hf;
if ((rv = x_wfullpath(file, X_MAX_PATH, argv[i]))) {
- if (verbose) {
+ if (xtrace) {
warnx("'%s' -- %s", argv[i], cstrerror(rv));
}
return rv;
@@ -2672,7 +3221,7 @@
FILE_ATTRIBUTE_NORMAL, NULL);
if (hf == INVALID_HANDLE_VALUE) {
rv = x_cerror(0);
- if (verbose) {
+ if (xtrace) {
warnx("'%S' -- %s", file, cstrerror(rv));
}
return rv;
@@ -2700,10 +3249,10 @@
}
if (!SetFileTime(hf, NULL, at, mt)) {
rv = x_cerror(0);
- if (verbose)
+ if (xtrace)
warnx("'%S' -- %s", file, cstrerror(rv));
}
- if (verbose) {
+ if (xtrace) {
if (at || mt)
warnx("'%S' modified.", file);
else
@@ -2744,11 +3293,11 @@
char **mainargv = NULL;
char wcpath[MAX_PATH + 32] = { 0 };
- while ((ch = getopt(argc, argv, "cefrshqv", 1)) != EOF) {
+ while ((ch = getopt(argc, argv, "cefrshqV", 1)) != EOF) {
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -2757,8 +3306,11 @@
return prog_exec_usage(EINVAL);
break;
case 'v':
- verbose = 1;
+ xtrace = 1;
break;
+ case 'V':
+ xtrace = 9;
+ break;
case 'q':
xquiet = 1;
break;
@@ -2875,10 +3427,10 @@
SetConsoleCtrlHandler((PHANDLER_ROUTINE)console_handler, TRUE);
if (checkbinary(mainargv[0])) {
- if (verbose)
+ if (xtrace > 1)
fprintf(stdout, "Executing %s\n", mainargv[0]);
rv = _spawnvpe(_P_WAIT, mainargv[0], mainargv, mainenvp);
- if (verbose)
+ if (xtrace)
fprintf(stdout, "%s: exit(%d)\n", mainargv[0], rv);
}
else {
@@ -2907,11 +3459,11 @@
char patern[MAX_PATH];
register char *start, *trv, *suffp;
- while ((ch = getopt(argc, argv, "dquhqv", 1)) != EOF) {
+ while ((ch = getopt(argc, argv, "dquhqvV", 1)) != EOF) {
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -2920,8 +3472,11 @@
return prog_mktemp_usage(1);
break;
case 'v':
- verbose = 1;
+ xtrace = 1;
break;
+ case 'V':
+ xtrace = 9;
+ break;
case 'q':
xquiet = 1;
break;
@@ -2974,15 +3529,15 @@
start = trv + 1;
for (;;) {
- if (access(path, 0)) {
+ if (!x_fattrib(path)) {
if (errno == ENOENT) {
if (mdir) {
- if (mkdir(path)) {
+ if (x_createdir(path)) {
x_perror(0, path);
return 1;
}
if (unsafe)
- rmdir(path);
+ x_rmdir(path);
}
else {
FILE *fp = fopen(path, "w");
@@ -3086,7 +3641,7 @@
switch (ch) {
case '.':
if (!stricmp(optarg, "verbose"))
- verbose = 1;
+ xtrace = 1;
else if (!stricmp(optarg, "version"))
return print_banner(1);
else if (!stricmp(optarg, "help"))
@@ -3097,8 +3652,10 @@
return prog_image_usage(1);
break;
case 'v':
+ xtrace = 1;
+ break;
case 'V':
- verbose = 1;
+ xtrace = 9;
break;
case 'q':
case 'Q':
@@ -3541,11 +4098,151 @@
x_free(pidata);
pidata = NULL;
}
- if (verbose)
+ if (xtrace)
fputc('\n', stdout);
return 0;
}
+static int prog_html(int argc, const char **argv, const char **env)
+{
+ int ch, rv = 0;
+ char *p;
+ char title[MAX_PATH] = { 0 };
+ int w = 0;
+ int h = 0;
+ int t = INFINITE;
+ int flags = 0;
+ char *page = NULL;
+ char *output = NULL;
+ char *params = NULL;
+
+ if (!GuiInitialize()) {
+ return x_perror(0, "Windows GUI");
+ }
+ while ((ch = getopt(argc, argv, "g:n:o:p:st:T:qhqv", 1)) != EOF) {
+ switch (ch) {
+ case '.':
+ if (!stricmp(optarg, "verbose"))
+ xtrace = 1;
+ else if (!stricmp(optarg, "version"))
+ return print_banner(1);
+ else if (!stricmp(optarg, "help"))
+ return prog_html_usage(0);
+ else
+ return prog_html_usage(1);
+ break;
+ case 'v':
+ xtrace = 1;
+ break;
+ case 'V':
+ xtrace = 9;
+ break;
+ case 'q':
+ xquiet = 1;
+ break;
+ case 'h':
+ return prog_html_usage(0);
+ break;
+ case 'g':
+ w = atoi(optarg);
+ if (!(p = strchr(optarg, 'x')))
+ p = strchr(optarg, 'X');
+ if (p++)
+ h = atoi(p);
+ if (w < 1 || h < 1) {
+ return x_perror(EINVAL, "Geometry");
+ }
+ break;
+ case 'n':
+ x_strncpy(title, optarg, MAX_PATH);
+ break;
+ case 'o':
+ output = x_fullpath(optarg);
+ break;
+ case 'p':
+ params = x_strdup(optarg);
+ break;
+ case 's':
+ flags = 1;
+ break;
+ case 't':
+ t = atoi(optarg);
+ break;
+ case 'T':
+ t = atoi(optarg) * 1000;
+ break;
+ case '?':
+ case ':':
+ return 1;
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+ if (argc < 1) {
+ return prog_html_usage(EINVAL);
+ }
+ if (!(page = x_fullpath(argv[0]))) {
+ return x_perror(EINVAL, argv[0]);
+ }
+ if (!title[0]) {
+ FILE *f;
+ char buff[SIZ_BUFLEN];
+ char lbuf[SIZ_BUFLEN];
+ if (!(f = fopen(page, "r"))) {
+ rv = x_perror(0, page);
+ goto cleanup;
+ }
+ while (fgets(&buff[0], SIZ_BUFLEN, f)) {
+ char *e;
+ strcpy(lbuf, buff);
+ strlwr(lbuf);
+ if ((p = strstr(lbuf, "<title>")) && *(p += 7)) {
+ if ((e = strstr(p, "</title>"))) {
+ size_t ps = p - lbuf;
+ size_t pe = e - lbuf;
+ x_strncpy(lbuf, buff + ps, pe - ps + 1);
+ p = rltrim(lbuf);
+ strcpy(title, p);
+ break;
+ }
+ }
+ }
+ fclose(f);
+ if (!title[0]) {
+ rv = x_perror(EINVAL, "Html <title></title> tag");
+ goto cleanup;
+ }
+ }
+ if (w < 1)
+ w = DEF_WWIDTH;
+ if (h < 1)
+ h = DEF_WHEIGHT;
+
+ if (xtrace > 1) {
+ warnx("Html %s", page);
+ warnx("Title %s", title);
+ warnx("Geometry %d x %d", w, h);
+ }
+
+ if (!RunCustomPage(page,
+ title,
+ params,
+ w,
+ h,
+ t,
+ flags,
+ output)) {
+ rv = x_cerror(0);
+ }
+
+cleanup:
+ x_free(page);
+ x_free(params);
+ x_free(output);
+ return rv;
+}
+
/*
* ---------------------------------------------------------------------
* end of programs
@@ -3567,6 +4264,7 @@
{ "mktemp", prog_mktemp },
{ "image", prog_image },
{ "coff", prog_image },
+ { "html", prog_html },
{ NULL, NULL }
};
@@ -3621,9 +4319,9 @@
if ((e = getenv("XTOOLS_PAUSE")) != NULL)
xtools_pause = 1;
if ((e = getenv("XTOOLS_VERBOSE")) != NULL) {
- verbose = atoi(e);
- if (!verbose)
- verbose = 1;
+ xtrace = atoi(e);
+ if (!xtrace)
+ xtrace = 1;
}
}
@@ -3634,6 +4332,9 @@
if (cleared++)
return;
/* Make any cleanup here */
+
+ /* Finally terminate the GUI */
+ GuiTerminate();
}
int wmain(int argc, const wchar_t **wargv, const wchar_t **wenv)
@@ -3691,7 +4392,7 @@
getch();
fprintf(stdout, "\n");
}
- if (verbose)
+ if (xtrace)
warnx("exit(%d)", rv);
exit(rv);
/*
Modified: trunk/build/install/xtool/xtool.rc
===================================================================
--- trunk/build/install/xtool/xtool.rc 2008-04-04 06:18:32 UTC (rev 1518)
+++ trunk/build/install/xtool/xtool.rc 2008-04-04 16:17:51 UTC (rev 1519)
@@ -26,6 +26,10 @@
#include <windows.h>
+#define IDI_MAINICON 101
+#define IDI_RHELICON 102
+
+
#define STR_COPYRIGHT "Copyright � 2008 Red Hat Middleware, LLC. " \
"or its licensors, as applicable."
@@ -43,6 +47,8 @@
IDI_MAINICON ICON "jboss.ico"
IDI_RHELICON ICON "redhat.ico"
+CREATEPROCESS_MANIFEST_RESOURCE_ID RT_MANIFEST "commonc.manifest"
+
1 VERSIONINFO
FILEVERSION CSV_VERSION
PRODUCTVERSION CSV_VERSION