X-Git-Url: https://ncurses.scripts.mit.edu/?p=ncurses.git;a=blobdiff_plain;f=ncurses%2Ftrace%2Flib_trace.c;h=7e2ca854e656e158a4538dc174ba73ea50d1da9d;hp=eda50085c6ddabb7efd7f84724cb55858f5860ac;hb=8890c8f28a1db5995ef17f52a7d8c0b9cf574210;hpb=eccca377f55c70b12e3e92621d94d1e1c1fcfb7d diff --git a/ncurses/trace/lib_trace.c b/ncurses/trace/lib_trace.c index eda50085..7e2ca854 100644 --- a/ncurses/trace/lib_trace.c +++ b/ncurses/trace/lib_trace.c @@ -47,7 +47,7 @@ #include -MODULE_ID("$Id: lib_trace.c,v 1.91 2019/01/21 14:51:38 tom Exp $") +MODULE_ID("$Id: lib_trace.c,v 1.94 2019/12/07 22:32:36 tom Exp $") NCURSES_EXPORT_VAR(unsigned) _nc_tracing = 0; /* always define this */ @@ -91,14 +91,18 @@ NCURSES_EXPORT_VAR(long) _nc_outchars = 0; #define MyPath _nc_globals.trace_fname #define MyLevel _nc_globals.trace_level #define MyNested _nc_globals.nested_tracef +#endif /* TRACE */ -NCURSES_EXPORT(void) -trace(const unsigned int tracelevel) +NCURSES_EXPORT(unsigned) +curses_trace(unsigned tracelevel) { + unsigned result; +#if defined(TRACE) + result = _nc_tracing; if ((MyFP == 0) && tracelevel) { MyInit = TRUE; if (MyFD >= 0) { - MyFP = fdopen(MyFD, "wb"); + MyFP = fdopen(MyFD, BIN_W); } else { if (MyPath[0] == '\0') { size_t size = sizeof(MyPath) - 12; @@ -115,7 +119,7 @@ trace(const unsigned int tracelevel) } if (_nc_access(MyPath, W_OK) < 0 || (MyFD = open(MyPath, O_CREAT | O_EXCL | O_RDWR, 0600)) < 0 - || (MyFP = fdopen(MyFD, "wb")) == 0) { + || (MyFP = fdopen(MyFD, BIN_W)) == 0) { ; /* EMPTY */ } } @@ -146,6 +150,18 @@ trace(const unsigned int tracelevel) _nc_tracing = tracelevel; _tracef("tracelevel=%#x", tracelevel); } +#else + (void) tracelevel; + result = 0; +#endif + return result; +} + +#if defined(TRACE) +NCURSES_EXPORT(void) +trace(const unsigned int tracelevel) +{ + curses_trace(tracelevel); } static void