summaryrefslogtreecommitdiffstats
path: root/tools/fwpatcher
diff options
context:
space:
mode:
authorThom Johansen <thomj@rockbox.org>2005-06-12 12:40:46 +0000
committerThom Johansen <thomj@rockbox.org>2005-06-12 12:40:46 +0000
commit3c30ee51d89ac49ad0790889d554c760367e6ec9 (patch)
treec5c9f845da7484518fcfd314986937131603cf7c /tools/fwpatcher
parent2528e7c0236d2240af19499b1bf6d82555514fe4 (diff)
downloadrockbox-3c30ee51d89ac49ad0790889d554c760367e6ec9.tar.gz
rockbox-3c30ee51d89ac49ad0790889d554c760367e6ec9.tar.bz2
rockbox-3c30ee51d89ac49ad0790889d554c760367e6ec9.zip
Command line support for fwpatcher by Dave Hooper.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6684 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/fwpatcher')
-rw-r--r--tools/fwpatcher/main.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/tools/fwpatcher/main.c b/tools/fwpatcher/main.c
index 7f2eda8fd3..ca11fbaefd 100644
--- a/tools/fwpatcher/main.c
+++ b/tools/fwpatcher/main.c
@@ -337,18 +337,72 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
TEXT("Success"), MB_OK);
}
break;
+ case WM_USER:
+ /* command line driven patch button */
+ SetWindowText(controls[EDIT_FILENAME], (LPCTSTR)wParam);
+ SendMessage(hwnd, WM_COMMAND, 0, (LPARAM)(controls[BUTTON_PATCH]) );
+ break;
default:
return DefWindowProc(hwnd, msg, wParam, lParam);
}
return 0;
}
+void getargs(LPTSTR p, int * argc, LPCTSTR * argv, int MAXARGS)
+{
+ int quote=FALSE,whitespace=FALSE;
+ LPCTSTR tok=p;
+ *argc=0;
+ while(*argc<MAXARGS)
+ {
+ if((*p==TEXT(' ') || *p==TEXT('\0')) && !quote)
+ {
+ if(!whitespace)
+ {
+ whitespace=TRUE;
+ *argv++ = tok;
+ (*argc)++;
+ };
+ if(*p==TEXT('\0'))
+ break; // end of cmd line
+ *p=TEXT('\0');
+ p++;
+ }
+ else
+ {
+ if(whitespace)
+ tok=p;
+ whitespace=FALSE;
+ if(*p==TEXT('\"'))
+ {
+ *p=TEXT(' ');
+ if(!quote)
+ {
+ p++;
+ tok=p;
+ }
+ quote = !quote;
+ }
+ else p++;
+ }
+ }
+}
+
+#define MAXARGC 4
+
int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance,
LPSTR command_line, int command_show)
{
HWND window;
WNDCLASSEX wc;
MSG msg;
+ int argc;
+ LPCTSTR argv[MAXARGC] = { NULL };
+ LPTSTR cmdline = GetCommandLine();
+
+ getargs(cmdline, &argc, argv, MAXARGC);
+ if (argc > 1)
+ command_show = SW_HIDE;
rbicon = LoadIcon(instance, MAKEINTRESOURCE(IDI_RBICON));
ZeroMemory(&wc, sizeof(wc));
@@ -368,6 +422,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance,
if (!window) return 0;
ShowWindow(window, command_show);
+
+ if (argc > 1) {
+ SendMessage(window, WM_USER, (WPARAM)(argv[1]), 0);
+ SendMessage(window, WM_CLOSE, 0, 0);
+ }
+
while (GetMessage(&msg, 0, 0, 0) > 0) {
if (!IsDialogMessage(window, &msg)) {
TranslateMessage(&msg);