soc/intel/xeon_sp/util: Enhance lock_pam0123
[coreboot2.git] / payloads / libpayload / curses / PDCurses / pdcurses / inchstr.c
blobf061cdb38f5d9ba3cf18c2fb7fc3ba876e163766
1 /* Public Domain Curses */
3 #include <curspriv.h>
5 RCSID("$Id: inchstr.c,v 1.34 2008/07/13 16:08:18 wmcbrine Exp $")
7 /*man-start**************************************************************
9 Name: inchstr
11 Synopsis:
12 int inchstr(chtype *ch);
13 int inchnstr(chtype *ch, int n);
14 int winchstr(WINDOW *win, chtype *ch);
15 int winchnstr(WINDOW *win, chtype *ch, int n);
16 int mvinchstr(int y, int x, chtype *ch);
17 int mvinchnstr(int y, int x, chtype *ch, int n);
18 int mvwinchstr(WINDOW *, int y, int x, chtype *ch);
19 int mvwinchnstr(WINDOW *, int y, int x, chtype *ch, int n);
21 int in_wchstr(cchar_t *wch);
22 int in_wchnstr(cchar_t *wch, int n);
23 int win_wchstr(WINDOW *win, cchar_t *wch);
24 int win_wchnstr(WINDOW *win, cchar_t *wch, int n);
25 int mvin_wchstr(int y, int x, cchar_t *wch);
26 int mvin_wchnstr(int y, int x, cchar_t *wch, int n);
27 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch);
28 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n);
30 Description:
31 These routines read a chtype or cchar_t string from the window,
32 starting at the current or specified position, and ending at the
33 right margin, or after n elements, whichever is less.
35 Return Value:
36 All functions return the number of elements read, or ERR on
37 error.
39 Portability X/Open BSD SYS V
40 inchstr Y - 4.0
41 winchstr Y - 4.0
42 mvinchstr Y - 4.0
43 mvwinchstr Y - 4.0
44 inchnstr Y - 4.0
45 winchnstr Y - 4.0
46 mvinchnstr Y - 4.0
47 mvwinchnstr Y - 4.0
48 in_wchstr Y
49 win_wchstr Y
50 mvin_wchstr Y
51 mvwin_wchstr Y
52 in_wchnstr Y
53 win_wchnstr Y
54 mvin_wchnstr Y
55 mvwin_wchnstr Y
57 **man-end****************************************************************/
59 int winchnstr(WINDOW *win, chtype *ch, int n)
61 chtype *src;
62 int i;
64 PDC_LOG(("winchnstr() - called\n"));
66 if (!win || !ch || n < 0)
67 return ERR;
69 if ((win->_curx + n) > win->_maxx)
70 n = win->_maxx - win->_curx;
72 src = win->_y[win->_cury] + win->_curx;
74 for (i = 0; i < n; i++)
75 *ch++ = *src++;
77 *ch = (chtype)0;
79 return OK;
82 int inchstr(chtype *ch)
84 PDC_LOG(("inchstr() - called\n"));
86 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
89 int winchstr(WINDOW *win, chtype *ch)
91 PDC_LOG(("winchstr() - called\n"));
93 return winchnstr(win, ch, win->_maxx - win->_curx);
96 int mvinchstr(int y, int x, chtype *ch)
98 PDC_LOG(("mvinchstr() - called: y %d x %d\n", y, x));
100 if (move(y, x) == ERR)
101 return ERR;
103 return winchnstr(stdscr, ch, stdscr->_maxx - stdscr->_curx);
106 int mvwinchstr(WINDOW *win, int y, int x, chtype *ch)
108 PDC_LOG(("mvwinchstr() - called:\n"));
110 if (wmove(win, y, x) == ERR)
111 return ERR;
113 return winchnstr(win, ch, win->_maxx - win->_curx);
116 int inchnstr(chtype *ch, int n)
118 PDC_LOG(("inchnstr() - called\n"));
120 return winchnstr(stdscr, ch, n);
123 int mvinchnstr(int y, int x, chtype *ch, int n)
125 PDC_LOG(("mvinchnstr() - called: y %d x %d n %d\n", y, x, n));
127 if (move(y, x) == ERR)
128 return ERR;
130 return winchnstr(stdscr, ch, n);
133 int mvwinchnstr(WINDOW *win, int y, int x, chtype *ch, int n)
135 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
137 if (wmove(win, y, x) == ERR)
138 return ERR;
140 return winchnstr(win, ch, n);
143 #ifdef PDC_WIDE
144 int win_wchnstr(WINDOW *win, cchar_t *wch, int n)
146 PDC_LOG(("win_wchnstr() - called\n"));
148 return winchnstr(win, wch, n);
151 int in_wchstr(cchar_t *wch)
153 PDC_LOG(("in_wchstr() - called\n"));
155 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
158 int win_wchstr(WINDOW *win, cchar_t *wch)
160 PDC_LOG(("win_wchstr() - called\n"));
162 return win_wchnstr(win, wch, win->_maxx - win->_curx);
165 int mvin_wchstr(int y, int x, cchar_t *wch)
167 PDC_LOG(("mvin_wchstr() - called: y %d x %d\n", y, x));
169 if (move(y, x) == ERR)
170 return ERR;
172 return win_wchnstr(stdscr, wch, stdscr->_maxx - stdscr->_curx);
175 int mvwin_wchstr(WINDOW *win, int y, int x, cchar_t *wch)
177 PDC_LOG(("mvwin_wchstr() - called:\n"));
179 if (wmove(win, y, x) == ERR)
180 return ERR;
182 return win_wchnstr(win, wch, win->_maxx - win->_curx);
185 int in_wchnstr(cchar_t *wch, int n)
187 PDC_LOG(("in_wchnstr() - called\n"));
189 return win_wchnstr(stdscr, wch, n);
192 int mvin_wchnstr(int y, int x, cchar_t *wch, int n)
194 PDC_LOG(("mvin_wchnstr() - called: y %d x %d n %d\n", y, x, n));
196 if (move(y, x) == ERR)
197 return ERR;
199 return win_wchnstr(stdscr, wch, n);
202 int mvwin_wchnstr(WINDOW *win, int y, int x, cchar_t *wch, int n)
204 PDC_LOG(("mvwinchnstr() - called: y %d x %d n %d \n", y, x, n));
206 if (wmove(win, y, x) == ERR)
207 return ERR;
209 return win_wchnstr(win, wch, n);
211 #endif