diff --git a/curses.h b/curses.h index 65c1db1a..af7b8265 100644 --- a/curses.h +++ b/curses.h @@ -30,7 +30,7 @@ Defined by this header: **man-end****************************************************************/ #define PDCURSES 1 /* PDCurses-only routines */ -#define PDC_BUILD 3702 +#define PDC_BUILD 3703 #define PDC_VER_MAJOR 3 #define PDC_VER_MINOR 7 #define PDC_VERDOT "3.7" @@ -94,6 +94,33 @@ typedef chtype cchar_t; typedef chtype attr_t; +/*---------------------------------------------------------------------- + * + * Version Info + * + */ + +/* Use this structure with PDC_get_version() for run-time info about the + way the library was built, in case it doesn't match the header. */ + +typedef struct +{ + short flags; /* flags OR'd together (see below) */ + short build; /* PDC_BUILD at compile time */ + unsigned char major; /* PDC_VER_MAJOR */ + unsigned char minor; /* PDC_VER_MINOR */ + unsigned char csize; /* sizeof chtype */ + unsigned char bsize; /* sizeof bool */ +} PDC_VERSION; + +enum +{ + PDC_VFLAG_DEBUG = 1, /* set if built with -DPDCDEBUG */ + PDC_VFLAG_WIDE = 2, /* -DPDC_WIDE */ + PDC_VFLAG_UTF8 = 4, /* -DPDC_FORCE_UTF8 */ + PDC_VFLAG_DLL = 8 /* -DPDC_DLL_BUILD */ +}; + /*---------------------------------------------------------------------- * * Mouse Interface -- SYSVR4, with extensions @@ -1277,6 +1304,7 @@ PDCEX wchar_t *slk_wlabel(int); #endif PDCEX void PDC_debug(const char *, ...); +PDCEX void PDC_get_version(PDC_VERSION *); PDCEX int PDC_ungetch(int); PDCEX int PDC_set_blink(bool); PDCEX int PDC_set_bold(bool); diff --git a/pdcurses/initscr.c b/pdcurses/initscr.c index e30ff1fa..e9a059d3 100644 --- a/pdcurses/initscr.c +++ b/pdcurses/initscr.c @@ -20,6 +20,7 @@ initscr int resize_term(int nlines, int ncols); bool is_termresized(void); const char *curses_version(void); + void PDC_get_version(PDC_VERSION *ver); ### Description @@ -72,6 +73,9 @@ initscr curses_version() returns a string describing the version of PDCurses. + PDC_get_version() fills a PDC_VERSION structure provided by the user + with more detailed version info (see curses.h). + ### Return Value All functions return NULL on error, except endwin(), which always @@ -345,3 +349,30 @@ const char *curses_version(void) { return _curses_notice; } + +void PDC_get_version(PDC_VERSION *ver) +{ + if (!ver) + return; + + ver->flags = 0 +#ifdef PDCDEBUG + | PDC_VFLAG_DEBUG +#endif +#ifdef PDC_WIDE + | PDC_VFLAG_WIDE +#endif +#ifdef PDC_FORCE_UTF8 + | PDC_VFLAG_UTF8 +#endif +#ifdef PDC_DLL_BUILD + | PDC_VFLAG_DLL +#endif + ; + + ver->build = PDC_BUILD; + ver->major = PDC_VER_MAJOR; + ver->minor = PDC_VER_MINOR; + ver->csize = sizeof(chtype); + ver->bsize = sizeof(bool); +}