Mercurial > dwindows
comparison win/dw.c @ 2398:4de830d3bf9e
Win: Remove winmain.c as it is unnecessary when using the dwmain() entrypoint macros.
Export _dw_convertargs() internal function for use in the dwmain macro.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Thu, 25 Mar 2021 21:38:58 +0000 |
parents | fad0821cb953 |
children | 0286ac44d347 |
comparison
equal
deleted
inserted
replaced
2397:f181963f23d5 | 2398:4de830d3bf9e |
---|---|
408 { WM_USER+100, DW_SIGNAL_HTML_RESULT }, | 408 { WM_USER+100, DW_SIGNAL_HTML_RESULT }, |
409 { WM_USER+101, DW_SIGNAL_HTML_CHANGED } | 409 { WM_USER+101, DW_SIGNAL_HTML_CHANGED } |
410 }; | 410 }; |
411 | 411 |
412 #ifdef BUILD_DLL | 412 #ifdef BUILD_DLL |
413 /* Old function to store the instance handle, kept for compatibilty. */ | |
413 void Win32_Set_Instance(HINSTANCE hInstance) | 414 void Win32_Set_Instance(HINSTANCE hInstance) |
414 { | 415 { |
415 _DWInstance = hInstance; | 416 _DWInstance = hInstance; |
416 } | 417 } |
417 #else | 418 #endif |
418 char **_convertargs(int *count, char *start) | 419 |
420 /* | |
421 * Internal function to convert WinMain arguments into main() style. | |
422 * Also saves the handle to the instance passed from WinMain(). | |
423 */ | |
424 char ** API _dw_convertargs(int *count, char *start, HINSTANCE hInstance) | |
419 { | 425 { |
420 char *tmp, *argstart, **argv; | 426 char *tmp, *argstart, **argv; |
421 int loc = 0, inquotes = 0; | 427 int loc = 0, inquotes = 0; |
422 | 428 |
429 _DWInstance = hInstance; | |
423 (*count) = 1; | 430 (*count) = 1; |
424 | 431 |
425 tmp = start; | 432 tmp = start; |
426 | 433 |
427 /* Count the number of entries */ | 434 /* Count the number of entries */ |
448 } | 455 } |
449 tmp++; | 456 tmp++; |
450 } | 457 } |
451 } | 458 } |
452 | 459 |
453 argv = (char **)malloc(sizeof(char *) * ((*count)+1)); | 460 argv = (char **)calloc(sizeof(char *), ((*count)+1)); |
454 argv[0] = calloc(261, 1); | 461 argv[0] = calloc(261, 1); |
455 GetModuleFileNameA(_DWInstance, argv[0], 260); | 462 GetModuleFileNameA(_DWInstance, argv[0], 260); |
456 | 463 |
457 argstart = tmp = start; | 464 argstart = tmp = start; |
458 | 465 |
496 argv[loc] = _strdup(argstart); | 503 argv[loc] = _strdup(argstart); |
497 } | 504 } |
498 argv[loc+1] = NULL; | 505 argv[loc+1] = NULL; |
499 return argv; | 506 return argv; |
500 } | 507 } |
501 | |
502 /* Ok this is a really big hack but what the hell ;) */ | |
503 int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) | |
504 { | |
505 char **argv; | |
506 int argc; | |
507 | |
508 _DWInstance = hInstance; | |
509 | |
510 argv = _convertargs(&argc, lpCmdLine); | |
511 | |
512 return main(argc, argv); | |
513 } | |
514 #endif | |
515 | 508 |
516 #ifdef UNICODE | 509 #ifdef UNICODE |
517 /* Macro and internal function to convert UTF8 to Unicode wide characters */ | 510 /* Macro and internal function to convert UTF8 to Unicode wide characters */ |
518 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) | 511 #define UTF8toWide(a) _myUTF8toWide(a, a ? _alloca(MultiByteToWideChar(CP_UTF8, 0, a, -1, NULL, 0) * sizeof(WCHAR)) : NULL) |
519 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf) | 512 LPWSTR _myUTF8toWide(const char *utf8string, void *outbuf) |