- if ((TraceFP == 0) && tracelevel) {
- const char *mode = _nc_globals.init_trace ? "ab" : "wb";
-
- if (TracePath[0] == '\0') {
- size_t size = sizeof(TracePath) - 12;
- if (getcwd(TracePath, size) == 0) {
- perror("curses: Can't get working directory");
- exit(EXIT_FAILURE);
+ unsigned result;
+
+#if defined(TRACE)
+ int bit;
+
+#define DATA(name) { name, #name }
+ static struct {
+ unsigned mask;
+ const char *name;
+ } trace_names[] = {
+ DATA(TRACE_TIMES),
+ DATA(TRACE_TPUTS),
+ DATA(TRACE_UPDATE),
+ DATA(TRACE_MOVE),
+ DATA(TRACE_CHARPUT),
+ DATA(TRACE_CALLS),
+ DATA(TRACE_VIRTPUT),
+ DATA(TRACE_IEVENT),
+ DATA(TRACE_BITS),
+ DATA(TRACE_ICALLS),
+ DATA(TRACE_CCALLS),
+ DATA(TRACE_DATABASE),
+ DATA(TRACE_ATTRS)
+ };
+#undef DATA
+
+ Locked(result = _nc_tracing);
+
+ if ((MyFP == 0) && tracelevel) {
+ MyInit = TRUE;
+ if (MyFD >= 0) {
+ MyFP = fdopen(MyFD, BIN_W);
+ } else {
+ if (MyPath[0] == '\0') {
+ size_t size = sizeof(MyPath) - 12;
+ if (getcwd(MyPath, size) == 0) {
+ perror("curses: Can't get working directory");
+ exit(EXIT_FAILURE);
+ }
+ MyPath[size] = '\0';
+ assert(strlen(MyPath) <= size);
+ _nc_STRCAT(MyPath, "/trace", sizeof(MyPath));
+ if (_nc_is_dir_path(MyPath)) {
+ _nc_STRCAT(MyPath, ".log", sizeof(MyPath));
+ }