ncurses 5.6 - patch 20070901
[ncurses.git] / ncurses / tinfo / lib_data.c
index d2d0d3ff6d8ec3bcfe5638e57a765e044e73f76a..ce355ea782e614f0059e303ec1f357255daa0426 100644 (file)
@@ -1,5 +1,5 @@
 /****************************************************************************
- * Copyright (c) 1998,1999 Free Software Foundation, Inc.                   *
+ * Copyright (c) 1998-2005,2007 Free Software Foundation, Inc.              *
  *                                                                          *
  * Permission is hereby granted, free of charge, to any person obtaining a  *
  * copy of this software and associated documentation files (the            *
@@ -29,6 +29,7 @@
 /****************************************************************************
  *  Author: Zeyd M. Ben-Halim <zmbenhal@netcom.com> 1992,1995               *
  *     and: Eric S. Raymond <esr@snark.thyrsus.com>                         *
+ *     and: Thomas E. Dickey                        1996-on                 *
  ****************************************************************************/
 
 /*
 
 #include <curses.priv.h>
 
-MODULE_ID("$Id: lib_data.c,v 1.14 1999/01/31 01:34:33 Ilya.Zakharevich Exp $")
+MODULE_ID("$Id: lib_data.c,v 1.28 2007/09/01 21:35:54 tom Exp $")
 
 /*
  * OS/2's native linker complains if we don't initialize public data when
  * constructing a dll (reported by J.J.G.Ripoll).
  */
-WINDOW *stdscr = 0;
-WINDOW *curscr = 0;
-WINDOW *newscr = 0;
+#if USE_REENTRANT
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(stdscr) (void)
+{
+    return SP ? SP->_stdscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(curscr) (void)
+{
+    return SP ? SP->_curscr : 0;
+}
+NCURSES_EXPORT(WINDOW *)
+NCURSES_PUBLIC_VAR(newscr) (void)
+{
+    return SP ? SP->_newscr : 0;
+}
+#else
+NCURSES_EXPORT_VAR(WINDOW *) stdscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) curscr = 0;
+NCURSES_EXPORT_VAR(WINDOW *) newscr = 0;
+#endif
 
-SCREEN *_nc_screen_chain = 0;
+NCURSES_EXPORT_VAR(SCREEN *) _nc_screen_chain = 0;
 
 /*
  * The variable 'SP' will be defined as a function on systems that cannot link
@@ -63,22 +82,142 @@ SCREEN *_nc_screen_chain = 0;
  * module coupling that increases the size of the executable.
  */
 #if BROKEN_LINKER
-static SCREEN *my_screen;
+static SCREEN *my_screen;
 
-SCREEN *_nc_screen(void)
+NCURSES_EXPORT(SCREEN *)
+_nc_screen(void)
 {
-       return my_screen;
+    return my_screen;
 }
 
-int _nc_alloc_screen(void)
+NCURSES_EXPORT(int)
+_nc_alloc_screen(void)
 {
-       return ((my_screen = typeCalloc(SCREEN, 1)) != 0);
+    return ((my_screen = typeCalloc(SCREEN, 1)) != 0);
 }
 
-void _nc_set_screen(SCREEN *sp)
+NCURSES_EXPORT(void)
+_nc_set_screen(SCREEN *sp)
 {
-       my_screen = sp;
+    my_screen = sp;
 }
+
 #else
-SCREEN *SP = NULL;             /* Some linkers require initialized data... */
+NCURSES_EXPORT_VAR(SCREEN *) SP = NULL; /* Some linkers require initialized data... */
+#endif
+/* *INDENT-OFF* */
+#define CHARS_0s { '\0' }
+
+#define TGETENT_0 { 0L, FALSE, NULL, NULL, NULL }
+#define TGETENT_0s { TGETENT_0, TGETENT_0, TGETENT_0, TGETENT_0 } 
+
+NCURSES_EXPORT_VAR(NCURSES_GLOBALS) _nc_globals = {
+    0,                         /* have_sigwinch */
+    0,                         /* cleanup_nested */
+
+    FALSE,                     /* init_signals */
+    FALSE,                     /* init_screen */
+
+    NULL,                      /* comp_sourcename */
+    NULL,                      /* comp_termtype */
+
+    FALSE,                     /* have_tic_directory */
+    FALSE,                     /* keep_tic_directory */
+    TERMINFO,                  /* tic_directory */
+
+    NULL,                      /* dbi_list */
+    0,                         /* dbi_size */
+
+    NULL,                      /* first_name */
+    NULL,                      /* keyname_table */
+
+    NULL,                      /* safeprint_buf */
+    0,                         /* safeprint_used */
+
+    TGETENT_0s,                        /* tgetent_cache */
+    0,                         /* tgetent_index */
+    0,                         /* tgetent_sequence */
+
+#if USE_HOME_TERMINFO
+    NULL,                      /* home_terminfo */
+#endif
+
+#if !USE_SAFE_SPRINTF
+    0,                         /* safeprint_cols */
+    0,                         /* safeprint_rows */
+#endif
+
+#ifdef TRACE
+    FALSE,                     /* init_trace */
+    CHARS_0s,                  /* trace_fname */
+    0,                         /* trace_level */
+    NULL,                      /* trace_fp */
+
+    NULL,                      /* tracearg_buf */
+    0,                         /* tracearg_used */
+
+    NULL,                      /* tracebuf_ptr */
+    0,                         /* tracebuf_used */
+
+    CHARS_0s,                  /* tracechr_buf */
+
+    NULL,                      /* tracedmp_buf */
+    0,                         /* tracedmp_used */
+
+    CHARS_0s,                  /* tracemse_buf */
+
+    NULL,                      /* tracetry_buf */
+    0,                         /* tracetry_used */
+
+#ifndef USE_TERMLIB
+    { CHARS_0s, CHARS_0s },    /* traceatr_color_buf */
+    0,                         /* traceatr_color_sel */
+    -1,                                /* traceatr_color_last */
+#endif /* USE_TERMLIB */
+
+#endif /* TRACE */
+#ifdef USE_PTHREADS
+    PTHREAD_MUTEX_INITIALIZER  /* mutex_set_SP */
+#endif
+};
+
+#define STACK_FRAME_0  { { 0 }, 0 }
+#define STACK_FRAME_0s { STACK_FRAME_0 }
+#define NUM_VARS_0s    { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }
+
+#define RIPOFF_0       { 0,0 }
+#define RIPOFF_0s      { RIPOFF_0 }
+
+NCURSES_EXPORT_VAR(NCURSES_PRESCREEN) _nc_prescreen = {
+    TRUE,                      /* use_env */
+    FALSE,                     /* filter_mode */
+    A_NORMAL,                  /* previous_attr */
+    RIPOFF_0s,                 /* ripoff */
+    NULL,                      /* rsp */
+    {                          /* tparm_state */
+#ifdef TRACE
+       NULL,                   /* tname */
+#endif
+       NULL,                   /* tparam_base */
+
+       STACK_FRAME_0s,         /* stack */
+       0,                      /* stack_ptr */
+
+       NULL,                   /* out_buff */
+       0,                      /* out_size */
+       0,                      /* out_used */
+
+       NULL,                   /* fmt_buff */
+       0,                      /* fmt_size */
+
+       NUM_VARS_0s,            /* dynamic_var */
+       NUM_VARS_0s,            /* static_vars */
+    },
+    NULL,                      /* saved_tty */
+#if BROKEN_LINKER || USE_REENTRANT
+    NULL,                      /* real_acs_map */
+    0,                         /* LINES */
+    0,                         /* COLS */
 #endif
+};
+/* *INDENT-ON* */