Mercurial > dwindows
comparison gtk4/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 | 9daee9d58956 |
children | 2b7babf491e1 |
comparison
equal
deleted
inserted
replaced
2900:fe31d4535270 | 2901:761b7a12b079 |
---|---|
1778 * ...: Additional variables for use in the format. | 1778 * ...: Additional variables for use in the format. |
1779 */ | 1779 */ |
1780 void API dw_debug(const char *format, ...) | 1780 void API dw_debug(const char *format, ...) |
1781 { | 1781 { |
1782 va_list args; | 1782 va_list args; |
1783 char outbuf[1025] = {0}; | |
1784 | 1783 |
1785 va_start(args, format); | 1784 va_start(args, format); |
1786 vsnprintf(outbuf, 1024, format, args); | 1785 vfprintf(stderr, format, args); |
1787 va_end(args); | 1786 va_end(args); |
1788 | 1787 } |
1789 fprintf(stderr, "%s", outbuf); | 1788 |
1789 void API dw_vdebug(const char *format, va_list args) | |
1790 { | |
1791 vfprintf(stderr, format, args); | |
1790 } | 1792 } |
1791 | 1793 |
1792 /* Internal version that does not use variable arguments */ | 1794 /* Internal version that does not use variable arguments */ |
1793 DW_FUNCTION_DEFINITION(dw_messagebox_int, int, const char *title, int flags, char *outbuf) | 1795 DW_FUNCTION_DEFINITION(dw_messagebox_int, int, const char *title, int flags, char *outbuf) |
1794 DW_FUNCTION_ADD_PARAM3(title, flags, outbuf) | 1796 DW_FUNCTION_ADD_PARAM3(title, flags, outbuf) |
1865 * ...: Additional variables for use in the format. | 1867 * ...: Additional variables for use in the format. |
1866 */ | 1868 */ |
1867 int API dw_messagebox(const char *title, int flags, const char *format, ...) | 1869 int API dw_messagebox(const char *title, int flags, const char *format, ...) |
1868 { | 1870 { |
1869 va_list args; | 1871 va_list args; |
1872 int rc; | |
1873 | |
1874 va_start(args, format); | |
1875 rc = dw_vmessagebox(title, flags, format, args); | |
1876 va_end(args); | |
1877 return rc; | |
1878 } | |
1879 | |
1880 int API dw_vmessagebox(const char *title, int flags, const char *format, va_list args) | |
1881 { | |
1870 char outbuf[1025] = {0}; | 1882 char outbuf[1025] = {0}; |
1871 | 1883 |
1872 va_start(args, format); | |
1873 vsnprintf(outbuf, 1024, format, args); | 1884 vsnprintf(outbuf, 1024, format, args); |
1874 va_end(args); | |
1875 | |
1876 return dw_messagebox_int(title, flags, outbuf); | 1885 return dw_messagebox_int(title, flags, outbuf); |
1877 } | 1886 } |
1878 | 1887 |
1879 /* | 1888 /* |
1880 * Minimizes or Iconifies a top-level window. | 1889 * Minimizes or Iconifies a top-level window. |