Static functions should probably not use the PDC_-style names, nor be

listed in the man page. More of these to do.
This commit is contained in:
William McBrine
2006-08-21 16:42:41 +00:00
parent ff594f8b9c
commit b59c9ba9a6
7 changed files with 107 additions and 206 deletions

View File

@@ -26,7 +26,7 @@
#undef mvwhline
#undef mvwvline
RCSID("$Id: border.c,v 1.32 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: border.c,v 1.33 2006/08/21 16:42:36 wmcbrine Exp $");
/*man-start**************************************************************
@@ -92,12 +92,12 @@ RCSID("$Id: border.c,v 1.32 2006/08/20 21:48:36 wmcbrine Exp $");
**man-end****************************************************************/
/* PDC_attr_passthru() -- Takes a single chtype 'ch' and checks if the
/* _attr_passthru() -- Takes a single chtype 'ch' and checks if the
current attribute of window 'win', as set by wattrset(), and/or the
current background of win, as set by wbkgd(), should by combined with
it. Attributes set explicitly in ch take precedence. */
static chtype PDC_attr_passthru(WINDOW *win, chtype ch)
static chtype _attr_passthru(WINDOW *win, chtype ch)
{
chtype attr, bktmp;
@@ -154,14 +154,14 @@ int wborder(WINDOW *win, chtype ls, chtype rs, chtype ts,
ymax = win->_maxy - 1;
xmax = win->_maxx - 1;
ls = PDC_attr_passthru(win, ls ? ls : ACS_VLINE);
rs = PDC_attr_passthru(win, rs ? rs : ACS_VLINE);
ts = PDC_attr_passthru(win, ts ? ts : ACS_HLINE);
bs = PDC_attr_passthru(win, bs ? bs : ACS_HLINE);
tl = PDC_attr_passthru(win, tl ? tl : ACS_ULCORNER);
tr = PDC_attr_passthru(win, tr ? tr : ACS_URCORNER);
bl = PDC_attr_passthru(win, bl ? bl : ACS_LLCORNER);
br = PDC_attr_passthru(win, br ? br : ACS_LRCORNER);
ls = _attr_passthru(win, ls ? ls : ACS_VLINE);
rs = _attr_passthru(win, rs ? rs : ACS_VLINE);
ts = _attr_passthru(win, ts ? ts : ACS_HLINE);
bs = _attr_passthru(win, bs ? bs : ACS_HLINE);
tl = _attr_passthru(win, tl ? tl : ACS_ULCORNER);
tr = _attr_passthru(win, tr ? tr : ACS_URCORNER);
bl = _attr_passthru(win, bl ? bl : ACS_LLCORNER);
br = _attr_passthru(win, br ? br : ACS_LRCORNER);
for (i = 1; i < xmax; i++)
{
@@ -226,7 +226,7 @@ int whline(WINDOW *win, chtype ch, int n)
endpos = min(win->_curx + n, win->_maxx);
ch = PDC_attr_passthru(win, ch ? ch : ACS_HLINE);
ch = _attr_passthru(win, ch ? ch : ACS_HLINE);
startpos = win->_curx;
@@ -265,7 +265,7 @@ int wvline(WINDOW *win, chtype ch, int n)
endpos = min(win->_cury + n, win->_maxy);
ch = PDC_attr_passthru(win, ch ? ch : ACS_VLINE);
ch = _attr_passthru(win, ch ? ch : ACS_VLINE);
for (n = win->_cury; n < endpos; n++)
{

View File

@@ -27,7 +27,7 @@
#define _INBUFSIZ 512 /* size of terminal input buffer */
#define NUNGETCH 256 /* max # chars to ungetch() */
RCSID("$Id: getch.c,v 1.34 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: getch.c,v 1.35 2006/08/21 16:42:37 wmcbrine Exp $");
static int c_pindex = 0; /* putter index */
static int c_gindex = 1; /* getter index */
@@ -109,74 +109,43 @@ static int c_ungch[NUNGETCH]; /* array of ungotten chars */
WINDOW *pdc_getch_win = NULL;
/*man-start**************************************************************
/* _breakout() - Check if input is pending, either directly from the
keyboard, or previously buffered. */
PDC_breakout() - check for type-ahead
PDCurses Description:
Check if input is pending, either directly from the keyboard,
or previously buffered.
PDCurses Return Value:
The PDC_breakout() routine returns TRUE if keyboard input is
pending otherwise FALSE is returned.
Portability:
PDCurses bool PDC_breakout(void);
**man-end****************************************************************/
static bool PDC_breakout(void)
static bool _breakout(void)
{
bool rc;
PDC_LOG(("PDC_breakout() - called\n"));
/* ungotten or buffered char */
rc = (c_ungind) || (c_pindex > c_gindex);
if (!rc)
rc = PDC_check_bios_key();
PDC_LOG(("PDC_breakout() - rc %d c_ungind %d c_pindex %d c_gindex %d\n",
PDC_LOG(("_breakout() - rc %d c_ungind %d c_pindex %d c_gindex %d\n",
rc, c_ungind, c_pindex, c_gindex));
return rc;
}
/*man-start**************************************************************
/* _rawgetch() - Gets a character without any interpretation and returns
it. If keypad mode is active for the designated window, function key
translation will be performed. Otherwise, function keys are ignored.
If nodelay mode is active in the window, then _rawgetch() returns -1
if no character is available.
PDC_rawgetch() - Returns the next uninterpreted character (if available).
WARNING: It is unknown whether the FUNCTION key translation is
performed at this level. --Frotz 911130 BUG */
PDCurses Description:
Gets a character without any interpretation at all and returns
it. If keypad mode is active for the designated window, function
key translation will be performed. Otherwise, function keys are
ignored. If nodelay mode is active in the window, then
PDC_rawgetch() returns -1 if no character is available.
WARNING: It is unknown whether the FUNCTION key translation
is performed at this level. --Frotz 911130 BUG
PDCurses Return Value:
This function returns OK on success and ERR on error.
Portability:
PDCurses int PDC_rawgetch(void);
**man-end****************************************************************/
static int PDC_rawgetch(void)
static int _rawgetch(void)
{
int c, oldc;
PDC_LOG(("PDC_rawgetch() - called\n"));
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
if ((SP->delaytenths || pdc_getch_win->_delayms ||
pdc_getch_win->_nodelay) && !PDC_breakout())
pdc_getch_win->_nodelay) && !_breakout())
return -1;
for (;;)
@@ -194,39 +163,21 @@ static int PDC_rawgetch(void)
}
}
/*man-start**************************************************************
/* _sysgetch() - Gets a character without normal ^S, ^Q, ^P and ^C
interpretation and returns it. If keypad mode is active for the
designated window, function key translation will be performed.
Otherwise, function keys are ignored. If nodelay mode is active in
the window, then sysgetch() returns -1 if no character is available. */
PDC_sysgetch() - Return a character using default system routines.
PDCurses Description:
This is a private PDCurses function.
Gets a character without normal ^S, ^Q, ^P and ^C interpretation
and returns it. If keypad mode is active for the designated
window, function key translation will be performed. Otherwise,
function keys are ignored. If nodelay mode is active in the
window, then sysgetch() returns -1 if no character is
available.
PDCurses Return Value:
This function returns OK upon success otherwise ERR is returned.
Portability:
PDCurses int PDC_sysgetch(void);
**man-end****************************************************************/
static int PDC_sysgetch(void)
static int _sysgetch(void)
{
int c;
PDC_LOG(("PDC_sysgetch() - called\n"));
if (pdc_getch_win == (WINDOW *)NULL)
return -1;
if ((SP->delaytenths || pdc_getch_win->_delayms ||
pdc_getch_win->_nodelay) && !PDC_breakout())
pdc_getch_win->_nodelay) && !_breakout())
return -1;
for (;;)
@@ -337,14 +288,14 @@ int wgetch(WINDOW *win)
for (;;) /* loop for any buffering */
{
if (SP->raw_inp)
key = PDC_rawgetch(); /* get a raw character */
key = _rawgetch(); /* get a raw character */
else
{
/* get a system character if break return proper */
bool cbr = PDC_get_ctrl_break();
PDC_set_ctrl_break(SP->orgcbr);
key = PDC_sysgetch();
key = _sysgetch();
PDC_set_ctrl_break(cbr);
}

View File

@@ -19,7 +19,7 @@
#include <curses.h>
#include <string.h>
RCSID("$Id: kernel.c,v 1.61 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: kernel.c,v 1.62 2006/08/21 16:42:37 wmcbrine Exp $");
RIPPEDOFFLINE linesripped[5];
char linesrippedoff = 0;
@@ -130,7 +130,7 @@ enum { PDC_SH_TTY, PDC_PR_TTY, PDC_SAVE_TTY };
**man-end****************************************************************/
static void PDC_save_mode(int i)
static void _save_mode(int i)
{
ctty[i].been_set = TRUE;
@@ -139,7 +139,7 @@ static void PDC_save_mode(int i)
PDC_save_screen_mode(i);
}
static int PDC_restore_mode(int i)
static int _restore_mode(int i)
{
if (ctty[i].been_set == TRUE)
{
@@ -169,7 +169,7 @@ int def_prog_mode(void)
{
PDC_LOG(("def_prog_mode() - called\n"));
PDC_save_mode(PDC_PR_TTY);
_save_mode(PDC_PR_TTY);
return OK;
}
@@ -178,7 +178,7 @@ int def_shell_mode(void)
{
PDC_LOG(("def_shell_mode() - called\n"));
PDC_save_mode(PDC_SH_TTY);
_save_mode(PDC_SH_TTY);
return OK;
}
@@ -187,7 +187,7 @@ int reset_prog_mode(void)
{
PDC_LOG(("reset_prog_mode() - called\n"));
PDC_restore_mode(PDC_PR_TTY);
_restore_mode(PDC_PR_TTY);
PDC_reset_prog_mode();
return OK;
@@ -197,7 +197,7 @@ int reset_shell_mode(void)
{
PDC_LOG(("reset_shell_mode() - called\n"));
PDC_restore_mode(PDC_SH_TTY);
_restore_mode(PDC_SH_TTY);
PDC_reset_shell_mode();
return OK;
@@ -207,14 +207,14 @@ int resetty(void)
{
PDC_LOG(("resetty() - called\n"));
return PDC_restore_mode(PDC_SAVE_TTY);
return _restore_mode(PDC_SAVE_TTY);
}
int savetty(void)
{
PDC_LOG(("savetty() - called\n"));
PDC_save_mode(PDC_SAVE_TTY);
_save_mode(PDC_SAVE_TTY);
return OK;
}

View File

@@ -18,7 +18,7 @@
#define CURSES_LIBRARY 1
#include <curses.h>
RCSID("$Id: overlay.c,v 1.21 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: overlay.c,v 1.22 2006/08/21 16:42:38 wmcbrine Exp $");
/*man-start**************************************************************
@@ -76,9 +76,9 @@ RCSID("$Id: overlay.c,v 1.21 2006/08/20 21:48:36 wmcbrine Exp $");
**man-end****************************************************************/
static int PDC_copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
int src_tc, int src_br, int src_bc, int dst_tr,
int dst_tc, bool overlay)
static int _copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
int src_tc, int src_br, int src_bc, int dst_tr,
int dst_tc, bool overlay)
{
int col, line, y1, fc, *minchng, *maxchng;
chtype *w1ptr, *w2ptr;
@@ -87,8 +87,6 @@ static int PDC_copy_win(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
int xdiff = src_bc - src_tc;
int ydiff = src_br - src_tr;
PDC_LOG(("PDC_copy_win() - called\n"));
if ((src_w == (WINDOW *)NULL) || (dst_w == (WINDOW *)NULL))
return ERR;
@@ -199,7 +197,7 @@ int overlay(const WINDOW *src_w, WINDOW *dst_w)
src_start_y = 0;
}
return PDC_copy_win(src_w, dst_w, src_start_y, src_start_x,
return _copy_win(src_w, dst_w, src_start_y, src_start_x,
src_start_y + ydiff, src_start_x + xdiff, dst_start_y,
dst_start_x, TRUE);
}
@@ -258,7 +256,7 @@ int overwrite(const WINDOW *src_w, WINDOW *dst_w)
src_start_y = 0;
}
return PDC_copy_win(src_w, dst_w, src_start_y, src_start_x,
return _copy_win(src_w, dst_w, src_start_y, src_start_x,
src_start_y + ydiff, src_start_x + xdiff, dst_start_y,
dst_start_x, FALSE);
}
@@ -294,6 +292,6 @@ int copywin(const WINDOW *src_w, WINDOW *dst_w, int src_tr,
src_end_y = src_tr + min_rows;
src_end_x = src_tc + min_cols;
return PDC_copy_win(src_w, dst_w, src_tr, src_tc,
return _copy_win(src_w, dst_w, src_tr, src_tc,
src_end_y, src_end_x, dst_tr, dst_tc, overlay);
}

View File

@@ -20,9 +20,7 @@
#include <stdlib.h>
#include <string.h>
RCSID("$Id: pdcwin.c,v 1.50 2006/07/31 22:28:53 wmcbrine Exp $");
static int PDC_newline(WINDOW *, int);
RCSID("$Id: pdcwin.c,v 1.51 2006/08/21 16:42:39 wmcbrine Exp $");
/*man-start**************************************************************
@@ -143,6 +141,27 @@ void PDC_sync(WINDOW *win)
wsyncup(win);
}
/* _newline() - Does line advance and returns the new cursor line.
If error, return -1. */
static int _newline(WINDOW *win, int lin)
{
if (win == (WINDOW *)NULL)
return -1;
if (++lin > win->_bmarg)
{
lin--;
if (win->_scroll)
scroll(win);
else
return -1;
}
return lin;
}
/*man-start**************************************************************
PDC_chadd() - Low level; Put a character to a window
@@ -271,7 +290,7 @@ int PDC_chadd(WINDOW *win, chtype ch, bool xlat, bool advance)
wclrtoeol(win);
if ((y = PDC_newline(win, y)) < 0)
if ((y = _newline(win, y)) < 0)
{
PDC_sync(win);
return ERR;
@@ -359,7 +378,7 @@ int PDC_chadd(WINDOW *win, chtype ch, bool xlat, bool advance)
x = 0;
if ((y = PDC_newline(win, y)) < 0)
if ((y = _newline(win, y)) < 0)
{
PDC_sync(win);
return ERR;
@@ -435,41 +454,3 @@ int PDC_chins(WINDOW *win, chtype c, bool xlat)
return PDC_chadd(win, c, xlat, FALSE);
}
/*man-start**************************************************************
PDC_newline() - Advances 1 newline from supplied line number.
PDCurses Description:
This is a private PDCurses routine.
Does line advance and returns the new cursor line. If error,
return -1.
PDCurses Return Value:
See above.
Portability:
PDCurses int PDC_newline(WINDOW *win, int lin);
**man-end****************************************************************/
static int PDC_newline(WINDOW *win, int lin)
{
PDC_LOG(("PDC_newline() - called: line %d\n", lin));
if (win == (WINDOW *)NULL)
return -1;
if (++lin > win->_bmarg)
{
lin--;
if (win->_scroll)
scroll(win);
else
return -1;
}
return lin;
}

View File

@@ -27,15 +27,15 @@
# include <ctype.h>
# include <limits.h>
static int PDC_vsscanf(const char *, const char *, va_list);
static int _pdc_vsscanf(const char *, const char *, va_list);
# define vsscanf PDC_vsscanf
# define vsscanf _pdc_vsscanf
#endif
/* undefine any macros for functions defined in this module */
#undef vw_scanw
RCSID("$Id: scanw.c,v 1.26 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: scanw.c,v 1.27 2006/08/21 16:42:40 wmcbrine Exp $");
/*man-start**************************************************************
@@ -162,38 +162,18 @@ int vw_scanw(WINDOW *win, const char *fmt, va_list varglist)
#ifndef HAVE_VSSCANF
/* Do not compile this module unless required. This is due to the
requirement of some compilers (at least Borland C++ 3.0) of having
to link with math libraries due to the use of floats in the code.
/* _pdc_vsscanf() - Internal routine to parse and format an input
buffer. It scans a series of input fields; each field is formatted
according to a supplied format string and the formatted input is
stored in the variable number of addresses passed. Returns the number
of input fields or EOF on error.
This module is based on vsscanf.c and input.c from emx 0.8f library
source which is Copyright (c) 1990-1992 by Eberhard Mattes.
Eberhard Mattes has kindly agreed to allow this module to be
incorporated into PDCurses. */
Don't compile this unless required. Some compilers (at least Borland
C++ 3.0) have to link with math libraries due to the use of floats.
/*man-start**************************************************************
PDC_vsscanf() - Internal routine to parse and format an input buffer.
PDCurses Description:
This is a private PDCurses routine.
Scan a series of input fields. Each field is formatted according
to a supplied format string and the formatted input is stored in
the variable number of addresses passed.
PDCurses Return Value:
This function returns the number of input fields or EOF on error.
PDCurses Errors:
If the supplied data is invalid or an incorrect number of
arguments are passed, EOF is returned as an error.
Portability:
PDCurses int PDC_vsscanf(const char *buf, const char *fmt,
va_list arg_ptr);
**man-end****************************************************************/
Based on vsscanf.c and input.c from emx 0.8f library source,
Copyright (c) 1990-1992 by Eberhard Mattes, who has kindly agreed to
its inclusion in PDCurses. */
#define WHITE(x) ((x) == ' ' || (x) == '\t' || (x) == '\n')
@@ -210,7 +190,7 @@ int vw_scanw(WINDOW *win, const char *fmt, va_list varglist)
--buf; --chars; \
} while (0)
static int PDC_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
static int _pdc_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
{
int count, chars, c, width, radix, d, i;
int *int_ptr;
@@ -226,8 +206,6 @@ static int PDC_vsscanf(const char *buf, const char *fmt, va_list arg_ptr)
int exp;
char eneg;
PDC_LOG(("PDC_vsscanf() - called\n"));
count = 0;
chars = 0;
c = 0;

View File

@@ -19,7 +19,7 @@
#include <curses.h>
#include <string.h>
RCSID("$Id: slk.c,v 1.28 2006/08/20 21:48:36 wmcbrine Exp $");
RCSID("$Id: slk.c,v 1.29 2006/08/21 16:42:41 wmcbrine Exp $");
/*man-start**************************************************************
@@ -102,8 +102,8 @@ static int label_fmt = 0;
static int label_line = 0;
void (*PDC_initial_slk)(void);
static void PDC_slk_init(void);
static void PDC_slk_calc(void);
static void _slk_initial(void);
static void _slk_calc(void);
static struct {
char label[32];
@@ -155,13 +155,13 @@ int slk_init(int fmt)
return ERR;
}
PDC_initial_slk = PDC_slk_init;
PDC_initial_slk = _slk_initial;
label_fmt = fmt;
return OK;
}
/* PDC_slk_set() Used to set a slk label to a string.
/* _slk_set_core() Used to set a slk label to a string.
label_num = 1 - 8 (or 10) (number of the label)
label_str = string (8 or 7 bytes total), NULL chars or NULL pointer
@@ -171,13 +171,11 @@ int slk_init(int fmt)
2 = right
save = 1 yes or 0 no */
static int PDC_slk_set(int label_num, const char *label_str,
int label_fmt, int save)
static int _slk_set_core(int label_num, const char *label_str,
int label_fmt, int save)
{
int i, num, slen, llen, col;
PDC_LOG(("PDC_slk_set() - called\n"));
if (label_num < 1 || label_num > labels ||
label_fmt < 0 || label_fmt > 2)
return ERR;
@@ -274,7 +272,7 @@ int slk_set(int label_num, const char *label_str, int label_fmt)
{
PDC_LOG(("slk_set() - called\n"));
return PDC_slk_set(label_num, label_str, label_fmt, 1);
return _slk_set_core(label_num, label_str, label_fmt, 1);
}
int slk_refresh(void)
@@ -313,7 +311,7 @@ int slk_clear(void)
for (i = 0; i < labels; ++i)
{
wattrset(SP->slk_winptr, slk_attributes[i]);
PDC_slk_set(i + 1, "", 0, 0);
_slk_set_core(i + 1, "", 0, 0);
}
return wrefresh(SP->slk_winptr);
@@ -329,7 +327,7 @@ int slk_restore(void)
for (i = 0; i < labels; ++i)
{
wattrset(SP->slk_winptr, slk_attributes[i]);
PDC_slk_set(i + 1, slk_save[i].label, slk_save[i].format, 0);
_slk_set_core(i + 1, slk_save[i].label, slk_save[i].format, 0);
}
SP->slk_winptr->_attrs = attr;
@@ -353,7 +351,7 @@ int slk_attron(const chtype attrs)
rc = wattron(SP->slk_winptr, attrs);
for (i = 0; i < labels; ++i)
PDC_slk_set(i + 1, slk_save[i].label, slk_save[i].format, 0);
_slk_set_core(i + 1, slk_save[i].label, slk_save[i].format, 0);
return rc;
}
@@ -374,7 +372,7 @@ int slk_attroff(const chtype attrs)
rc = wattroff(SP->slk_winptr, attrs);
for (i = 0; i < labels; ++i)
PDC_slk_set(i + 1, slk_save[i].label, slk_save[i].format, 0);
_slk_set_core(i + 1, slk_save[i].label, slk_save[i].format, 0);
return rc;
}
@@ -395,7 +393,7 @@ int slk_attrset(const chtype attrs)
rc = wattrset(SP->slk_winptr, attrs);
for (i = 0; i < labels; ++i)
PDC_slk_set(i + 1, slk_save[i].label, slk_save[i].format, 0);
_slk_set_core(i + 1, slk_save[i].label, slk_save[i].format, 0);
return rc;
}
@@ -409,7 +407,7 @@ int slk_color(short color_pair)
rc = wcolor_set(SP->slk_winptr, color_pair, NULL);
for (i = 0; i < labels; ++i)
PDC_slk_set(i + 1, slk_save[i].label, slk_save[i].format, 0);
_slk_set_core(i + 1, slk_save[i].label, slk_save[i].format, 0);
return rc;
}
@@ -421,13 +419,11 @@ int slk_attr_set(const attr_t attrs, short color_pair, void *opts)
return slk_attrset(attrs | COLOR_PAIR(color_pair));
}
static void PDC_slk_init(void)
static void _slk_initial(void)
{
int i;
chtype save_attr;
PDC_LOG(("PDC_slk_init() - called\n"));
if (label_fmt == 3)
{
SP->slklines = 2;
@@ -445,7 +441,7 @@ static void PDC_slk_init(void)
wattrset(SP->slk_winptr, A_REVERSE);
}
PDC_slk_calc();
_slk_calc();
/* if we have an index line, display it now */
@@ -466,12 +462,9 @@ static void PDC_slk_init(void)
touchwin(SP->slk_winptr);
}
static void PDC_slk_calc(void)
static void _slk_calc(void)
{
int i, center, col = 0;
PDC_LOG(("PDC_slk_calc() - called\n"));
label_length = COLS / labels;
/* set default attribute */