+NCURSES_EXPORT(int)
+NCURSES_SP_NAME(start_color) (NCURSES_SP_DCL0)
+{
+ int result = ERR;
+
+ T((T_CALLED("start_color()")));
+
+ if (SP_PARM == 0) {
+ result = ERR;
+ } else if (SP_PARM->_coloron) {
+ result = OK;
+ } else {
+
+ if (reset_color_pair() != TRUE) {
+ set_foreground_color(default_fg(), _nc_outch);
+ set_background_color(default_bg(), _nc_outch);
+ }
+
+ if (max_pairs > 0 && max_colors > 0) {
+ SP_PARM->_pair_limit = max_pairs;
+
+#if NCURSES_EXT_FUNCS
+ /*
+ * If using default colors, allocate extra space in table to
+ * allow for default-color as a component of a color-pair.
+ */
+ SP_PARM->_pair_limit += (1 + (2 * max_colors));
+#endif
+ SP_PARM->_pair_count = max_pairs;
+ SP_PARM->_color_count = max_colors;
+#if !USE_REENTRANT
+ COLOR_PAIRS = max_pairs;
+ COLORS = max_colors;
+#endif
+
+ SP_PARM->_color_pairs = TYPE_CALLOC(colorpair_t,
+ SP_PARM->_pair_limit);
+ if (SP_PARM->_color_pairs != 0) {
+ SP_PARM->_color_table = TYPE_CALLOC(color_t, max_colors);
+ if (SP_PARM->_color_table != 0) {
+ SP_PARM->_color_pairs[0] = PAIR_OF(default_fg(),
+ default_bg());
+ init_color_table();
+
+ T(("started color: COLORS = %d, COLOR_PAIRS = %d",
+ COLORS, COLOR_PAIRS));
+
+ SP_PARM->_coloron = 1;
+ result = OK;
+ } else if (SP_PARM->_color_pairs != 0) {
+ FreeAndNull(SP_PARM->_color_pairs);
+ }
+ }
+ } else {
+ result = OK;
+ }
+ }
+ returnCode(result);
+}
+
+#if NCURSES_SP_FUNCS
+NCURSES_EXPORT(int)
+start_color(void)
+{
+ return NCURSES_SP_NAME(start_color) (CURRENT_SCREEN);
+}
+#endif
+