Mercurial > dwindows
comparison os2/dw.c @ 2901:761b7a12b079
Add va_list versions of dw_debug() and dw_messagebox() for use in C++ bindings.
dw_vdebug() and dw_vmessagebox() work similarly to the standard library versions.
DW::App:Debug() and DW::App:MessageBox() use them for variable arguments.
author | bsmith@81767d24-ef19-dc11-ae90-00e081727c95 |
---|---|
date | Sun, 25 Dec 2022 00:20:49 +0000 |
parents | c250764b2f32 |
children | 3fe7641f027c |
comparison
equal
deleted
inserted
replaced
2900:fe31d4535270 | 2901:761b7a12b079 |
---|---|
4671 * ...: Additional variables for use in the format. | 4671 * ...: Additional variables for use in the format. |
4672 */ | 4672 */ |
4673 void API dw_debug(const char *format, ...) | 4673 void API dw_debug(const char *format, ...) |
4674 { | 4674 { |
4675 va_list args; | 4675 va_list args; |
4676 | |
4677 va_start(args, format); | |
4678 vfprintf(stderr, format, args); | |
4679 va_end(args); | |
4680 } | |
4681 | |
4682 void API dw_vdebug(const char *format, va_list args) | |
4683 { | |
4676 char outbuf[1025] = { 0 }; | 4684 char outbuf[1025] = { 0 }; |
4677 | 4685 |
4678 va_start(args, format); | |
4679 #if defined(__IBMC__) | 4686 #if defined(__IBMC__) |
4680 vsprintf(outbuf, format, args); | 4687 vsprintf(outbuf, format, args); |
4681 #else | 4688 #else |
4682 vsnprintf(outbuf, 1024, format, args); | 4689 vsnprintf(outbuf, 1024, format, args); |
4683 #endif | 4690 #endif |
4684 va_end(args); | |
4685 | 4691 |
4686 if(_PmPrintfString) | 4692 if(_PmPrintfString) |
4687 { | 4693 { |
4688 int len = strlen(outbuf); | 4694 int len = strlen(outbuf); |
4689 | 4695 |
4705 * ...: Additional variables for use in the format. | 4711 * ...: Additional variables for use in the format. |
4706 */ | 4712 */ |
4707 int API dw_messagebox(const char *title, int flags, const char *format, ...) | 4713 int API dw_messagebox(const char *title, int flags, const char *format, ...) |
4708 { | 4714 { |
4709 va_list args; | 4715 va_list args; |
4716 int rc; | |
4717 | |
4718 va_start(args, format); | |
4719 rc = dw_vmessagebox(title, flags, format, args); | |
4720 va_end(args); | |
4721 return rc; | |
4722 } | |
4723 | |
4724 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) | |
4725 { | |
4710 char outbuf[1025] = { 0 }; | 4726 char outbuf[1025] = { 0 }; |
4711 int rc; | 4727 int rc; |
4712 | 4728 |
4713 va_start(args, format); | |
4714 #if defined(__IBMC__) | 4729 #if defined(__IBMC__) |
4715 vsprintf(outbuf, format, args); | 4730 vsprintf(outbuf, format, args); |
4716 #else | 4731 #else |
4717 vsnprintf(outbuf, 1024, format, args); | 4732 vsnprintf(outbuf, 1024, format, args); |
4718 #endif | 4733 #endif |
4719 va_end(args); | |
4720 | 4734 |
4721 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)outbuf, (PSZ)title, 0, flags | MB_MOVEABLE); | 4735 rc = WinMessageBox(HWND_DESKTOP, HWND_DESKTOP, (PSZ)outbuf, (PSZ)title, 0, flags | MB_MOVEABLE); |
4722 if(rc == MBID_OK) | 4736 if(rc == MBID_OK) |
4723 return DW_MB_RETURN_OK; | 4737 return DW_MB_RETURN_OK; |
4724 else if(rc == MBID_YES) | 4738 else if(rc == MBID_YES) |