summaryrefslogtreecommitdiff
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.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)
337 TEXT("Success"), MB_OK); 337 TEXT("Success"), MB_OK);
338 } 338 }
339 break; 339 break;
340 case WM_USER:
341 /* command line driven patch button */
342 SetWindowText(controls[EDIT_FILENAME], (LPCTSTR)wParam);
343 SendMessage(hwnd, WM_COMMAND, 0, (LPARAM)(controls[BUTTON_PATCH]) );
344 break;
340 default: 345 default:
341 return DefWindowProc(hwnd, msg, wParam, lParam); 346 return DefWindowProc(hwnd, msg, wParam, lParam);
342 } 347 }
343 return 0; 348 return 0;
344} 349}
345 350
351void getargs(LPTSTR p, int * argc, LPCTSTR * argv, int MAXARGS)
352{
353 int quote=FALSE,whitespace=FALSE;
354 LPCTSTR tok=p;
355 *argc=0;
356 while(*argc<MAXARGS)
357 {
358 if((*p==TEXT(' ') || *p==TEXT('\0')) && !quote)
359 {
360 if(!whitespace)
361 {
362 whitespace=TRUE;
363 *argv++ = tok;
364 (*argc)++;
365 };
366 if(*p==TEXT('\0'))
367 break; // end of cmd line
368 *p=TEXT('\0');
369 p++;
370 }
371 else
372 {
373 if(whitespace)
374 tok=p;
375 whitespace=FALSE;
376 if(*p==TEXT('\"'))
377 {
378 *p=TEXT(' ');
379 if(!quote)
380 {
381 p++;
382 tok=p;
383 }
384 quote = !quote;
385 }
386 else p++;
387 }
388 }
389}
390
391#define MAXARGC 4
392
346int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance, 393int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance,
347 LPSTR command_line, int command_show) 394 LPSTR command_line, int command_show)
348{ 395{
349 HWND window; 396 HWND window;
350 WNDCLASSEX wc; 397 WNDCLASSEX wc;
351 MSG msg; 398 MSG msg;
399 int argc;
400 LPCTSTR argv[MAXARGC] = { NULL };
401 LPTSTR cmdline = GetCommandLine();
402
403 getargs(cmdline, &argc, argv, MAXARGC);
404 if (argc > 1)
405 command_show = SW_HIDE;
352 406
353 rbicon = LoadIcon(instance, MAKEINTRESOURCE(IDI_RBICON)); 407 rbicon = LoadIcon(instance, MAKEINTRESOURCE(IDI_RBICON));
354 ZeroMemory(&wc, sizeof(wc)); 408 ZeroMemory(&wc, sizeof(wc));
@@ -368,6 +422,12 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE prev_instance,
368 if (!window) return 0; 422 if (!window) return 0;
369 423
370 ShowWindow(window, command_show); 424 ShowWindow(window, command_show);
425
426 if (argc > 1) {
427 SendMessage(window, WM_USER, (WPARAM)(argv[1]), 0);
428 SendMessage(window, WM_CLOSE, 0, 0);
429 }
430
371 while (GetMessage(&msg, 0, 0, 0) > 0) { 431 while (GetMessage(&msg, 0, 0, 0) > 0) {
372 if (!IsDialogMessage(window, &msg)) { 432 if (!IsDialogMessage(window, &msg)) {
373 TranslateMessage(&msg); 433 TranslateMessage(&msg);