Cross Reference: utility.h
xref
: /
osnet-11
/
usr
/
src
/
lib
/
libeti
/
form
/
inc
/
utility.h
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
2
N/A
/*
2
N/A
* CDDL HEADER START
2
N/A
*
2
N/A
* The contents of this file are subject to the terms of the
2
N/A
* Common Development and Distribution License (the "License").
2
N/A
* You may not use this file except in compliance with the License.
2
N/A
*
2
N/A
* You can obtain a copy of the license at
usr
/
src
/
OPENSOLARIS.LICENSE
2
N/A
* or
http://www.opensolaris.org/os/licensing
.
2
N/A
* See the License for the specific language governing permissions
2
N/A
* and limitations under the License.
2
N/A
*
2
N/A
* When distributing Covered Code, include this CDDL HEADER in each
2
N/A
* file and include the License file at
usr
/
src
/
OPENSOLARIS.LICENSE
.
2
N/A
* If applicable, add the following below this CDDL HEADER, with the
2
N/A
* fields enclosed by brackets "[]" replaced with your own identifying
2
N/A
* information: Portions Copyright [yyyy] [name of copyright owner]
2
N/A
*
2
N/A
* CDDL HEADER END
2
N/A
*/
2
N/A
/* Copyright (c) 1988 AT&T */
2
N/A
/* All Rights Reserved */
2
N/A
2
N/A
2
N/A
/*
2
N/A
* Copyright (c) 1990, 2004, Oracle
and
/
or
its affiliates. All rights reserved.
2
N/A
*/
2
N/A
2
N/A
#
ifndef
_UTILITY_H
2
N/A
#
define
_UTILITY_H
2
N/A
2
N/A
#
include
<
form.h
>
2
N/A
#
include
<
memory.h
>
2
N/A
#
include
<
string.h
>
2
N/A
#
include
<
ctype.h
>
2
N/A
#
include
<
stdarg.h
>
2
N/A
#
include
<
sys
/
types.h
>
2
N/A
2
N/A
#
ifdef
__cplusplus
2
N/A
extern
"C"
{
2
N/A
#
endif
2
N/A
2
N/A
/* miscellaneous #defines */
2
N/A
typedef
int
BOOLEAN
;
2
N/A
2
N/A
#
define
MIN
(x, y) ((x) < (y) ? (x) : (y))
2
N/A
2
N/A
/* form status flags */
2
N/A
#
define
POSTED
0x0001
/* posted flag */
2
N/A
#
define
DRIVER
0x0002
/* inside
init
/
term
routine */
2
N/A
#
define
OVERLAY
0x0004
/*
insert
/
overlay
mode */
2
N/A
#
define
WIN_CHG
0x0010
/* window change (system flag) */
2
N/A
#
define
BUF_CHG
0x0020
/* buffer change (system flag) */
2
N/A
/* field status flags */
2
N/A
#
define
USR_CHG
0x0001
/* buffer change (user's flag) */
2
N/A
#
define
TOP_CHG
0x0002
/* toprow change (system flag) */
2
N/A
#
define
NEW_PAGE
0x0004
/* new page (system flag) */
2
N/A
#
define
GROWABLE
0x0008
/* growable page (system flag) */
2
N/A
/* field type status flags */
2
N/A
#
define
LINKED
0x0001
/* conjunctive field type */
2
N/A
#
define
ARGS
0x0002
/* has additional arguments */
2
N/A
#
define
CHOICE
0x0004
/* has choice functions */
2
N/A
/*
form
/
field
/
fieldtype
status manipulation macros */
2
N/A
#
define
Status
(f, s) ((f) ->
status
& (s))
2
N/A
#
define
Set
(f, s) ((f) ->
status
|= (s))
2
N/A
#
define
Clr
(f, s) ((f) ->
status
&= ~(s))
2
N/A
/*
form
/
field
option manipulation macros */
2
N/A
#
define
Opt
(f, x) ((f) ->
opts
& (x))
2
N/A
/*
alloc
/
free
with check */
2
N/A
#
define
Alloc
(x, t) ((x = (t *)
malloc
(
sizeof
(t))) != (t *)0)
2
N/A
#
define
arrayAlloc
(x, n, t) ((x = (t *)
malloc
((n) *
sizeof
(t))) != \
2
N/A
(t *)0)
2
N/A
#
define
Free
(x) {
if
(x)
free
(x); }
2
N/A
/* field type macros */
2
N/A
#
define
MakeArg
(f, p,
err
) (
_makearg
((f) ->
type
, p,
err
))
2
N/A
#
define
CopyArg
(f,
err
) (
_copyarg
((f) ->
type
, (f) ->
arg
,
err
))
2
N/A
#
define
FreeArg
(f) (
_freearg
((f) ->
type
, (f) ->
arg
))
2
N/A
#
define
CheckField
(f) (
_checkfield
((f) ->
type
, (f), (f) ->
arg
))
2
N/A
#
define
CheckChar
(f, c) (
_checkchar
((f) ->
type
, (c), (f) ->
arg
))
2
N/A
#
define
NextChoice
(f) (
_nextchoice
((f) ->
type
, (f), (f) ->
arg
))
2
N/A
#
define
PrevChoice
(f) (
_prevchoice
((f) ->
type
, (f), (f) ->
arg
))
2
N/A
#
define
IncrType
(
type
) {
if
(
type
) ++(
type
->
ref
); }
2
N/A
#
define
DecrType
(
type
) {
if
(
type
) --(
type
->
ref
); }
2
N/A
/*
form
/
field
init
/
term
calls */
2
N/A
#
define
init_field
(f) { \
2
N/A
if
((f) ->
fieldinit
) \
2
N/A
{ \
2
N/A
Set
(f,
DRIVER
); \
2
N/A
(*(f) ->
fieldinit
)(f); \
2
N/A
Clr
(f,
DRIVER
); \
2
N/A
} \
2
N/A
}
2
N/A
#
define
term_field
(f) { \
2
N/A
if
((f) ->
fieldterm
) \
2
N/A
{ \
2
N/A
Set
(f,
DRIVER
); \
2
N/A
(*(f) ->
fieldterm
)(f); \
2
N/A
Clr
(f,
DRIVER
); \
2
N/A
} \
2
N/A
}
2
N/A
#
define
init_form
(f) { \
2
N/A
if
((f) ->
forminit
) \
2
N/A
{ \
2
N/A
Set
(f,
DRIVER
); \
2
N/A
(*(f) ->
forminit
)(f); \
2
N/A
Clr
(f,
DRIVER
); \
2
N/A
} \
2
N/A
}
2
N/A
#
define
term_form
(f) { \
2
N/A
if
((f) ->
formterm
) \
2
N/A
{ \
2
N/A
Set
(f,
DRIVER
); \
2
N/A
(*(f) ->
formterm
)(f); \
2
N/A
Clr
(f,
DRIVER
); \
2
N/A
} \
2
N/A
}
2
N/A
/* page macros */
2
N/A
#
define
P(f) ((f) ->
curpage
)
2
N/A
#
define
Pmin
(f, p) ((f) ->
page
[p].
pmin
)
2
N/A
#
define
Pmax
(f, p) ((f) ->
page
[p].
pmax
)
2
N/A
#
define
Smin
(f, p) ((f) ->
page
[p].
smin
)
2
N/A
#
define
Smax
(f, p) ((f) ->
page
[p].
smax
)
2
N/A
/* form macros */
2
N/A
#
define
Form
(f) ((f) ? (f) :
_DEFAULT_FORM
)
2
N/A
#
define
ValidIndex
(f, i) ((i) >= 0 && (i) < (f) ->
maxfield
)
2
N/A
#
define
ValidPage
(f, i) ((i) >= 0 && (i) < (f) ->
maxpage
)
2
N/A
#
define
C(f) ((f) ->
current
)
2
N/A
#
define
W(f) ((f) -> w)
2
N/A
#
define
X(f) ((f) ->
curcol
)
2
N/A
#
define
Y(f) ((f) ->
currow
)
2
N/A
#
define
T(f) ((f) ->
toprow
)
2
N/A
#
define
B(f) ((f) ->
begincol
)
2
N/A
#
define
Xmax
(f) (C(f) ->
dcols
)
2
N/A
#
define
Ymax
(f) (C(f) ->
drows
)
2
N/A
#
define
Win
(f) ((f) ->
win
? (f) ->
win
:
stdscr
)
2
N/A
#
define
Sub
(f) ((f) ->
sub
? (f) ->
sub
:
Win
(f))
2
N/A
/* field macros */
2
N/A
#
define
Field
(f) ((f) ? (f) :
_DEFAULT_FIELD
)
2
N/A
#
define
Buf
(f) ((f) ->
buf
)
2
N/A
#
define
OneRow
(f) ((f)->
rows
+ (f)->
nrow
==
1
)
2
N/A
#
define
GrowSize
(f) (((f) ->
rows
+ (f) ->
nrow
) * (f) ->
cols
)
2
N/A
#
define
BufSize
(f) ((f) ->
drows
* (f) ->
dcols
)
2
N/A
#
define
Buffer
(f, n) (
Buf
(f) + (n) * (
BufSize
(f) +
1
))
2
N/A
#
define
LineBuf
(f, n) (
Buf
(f) + (n) * (f) ->
dcols
)
2
N/A
#
define
TotalBuf
(f) ((
BufSize
(f) +
1
) * ((f) ->
nbuf
+
1
))
2
N/A
#
define
Just
(f) ((f) ->
just
)
2
N/A
#
define
Fore
(f) ((f) ->
fore
)
2
N/A
#
define
Back
(f) ((f) ->
back
)
2
N/A
#
define
Pad
(f) ((f) ->
pad
)
2
N/A
/* system externs */
2
N/A
extern
int
_next_page
(
FORM
*);
/* REQ_NEXT_PAGE */
2
N/A
extern
int
_prev_page
(
FORM
*);
/* REQ_PREV_PAGE */
2
N/A
extern
int
_first_page
(
FORM
*);
/* REQ_FIRST_PAGE */
2
N/A
extern
int
_last_page
(
FORM
*);
/* REQ_LAST_PAGE */
2
N/A
2
N/A
extern
int
_next_field
(
FORM
*);
/* REQ_NEXT_FIELD */
2
N/A
extern
int
_prev_field
(
FORM
*);
/* REQ_PREV_FIELD */
2
N/A
extern
int
_first_field
(
FORM
*);
/* REQ_FIRST_FIELD */
2
N/A
extern
int
_last_field
(
FORM
*);
/* REQ_LAST_FIELD */
2
N/A
extern
int
_snext_field
(
FORM
*);
/* REQ_SNEXT_FIELD */
2
N/A
extern
int
_sprev_field
(
FORM
*);
/* REQ_SPREV_FIELD */
2
N/A
extern
int
_sfirst_field
(
FORM
*);
/* REQ_SFIRST_FIELD */
2
N/A
extern
int
_slast_field
(
FORM
*);
/* REQ_SLAST_FIELD */
2
N/A
extern
int
_left_field
(
FORM
*);
/* REQ_LEFT_FIELD */
2
N/A
extern
int
_right_field
(
FORM
*);
/* REQ_RIGHT_FIELD */
2
N/A
extern
int
_up_field
(
FORM
*);
/* REQ_UP_FIELD */
2
N/A
extern
int
_down_field
(
FORM
*);
/* REQ_DOWN_FIELD */
2
N/A
2
N/A
extern
int
_next_char
(
FORM
*);
/* REQ_NEXT_CHAR */
2
N/A
extern
int
_prev_char
(
FORM
*);
/* REQ_PREV_CHAR */
2
N/A
extern
int
_next_line
(
FORM
*);
/* REQ_NEXT_LINE */
2
N/A
extern
int
_prev_line
(
FORM
*);
/* REQ_PREV_LINE */
2
N/A
extern
int
_next_word
(
FORM
*);
/* REQ_NEXT_WORD */
2
N/A
extern
int
_prev_word
(
FORM
*);
/* REQ_PREV_WORD */
2
N/A
extern
int
_beg_field
(
FORM
*);
/* REQ_BEG_FIELD */
2
N/A
extern
int
_end_field
(
FORM
*);
/* REQ_END_FIELD */
2
N/A
extern
int
_beg_line
(
FORM
*);
/* REQ_BEG_LINE */
2
N/A
extern
int
_end_line
(
FORM
*);
/* REQ_END_LINE */
2
N/A
extern
int
_left_char
(
FORM
*);
/* REQ_LEFT_CHAR */
2
N/A
extern
int
_right_char
(
FORM
*);
/* REQ_RIGHT_CHAR */
2
N/A
extern
int
_up_char
(
FORM
*);
/* REQ_UP_CHAR */
2
N/A
extern
int
_down_char
(
FORM
*);
/* REQ_DOWN_CHAR */
2
N/A
2
N/A
extern
int
_new_line
(
FORM
*);
/* REQ_NEW_LINE */
2
N/A
extern
int
_ins_char
(
FORM
*);
/* REQ_INS_CHAR */
2
N/A
extern
int
_ins_line
(
FORM
*);
/* REQ_INS_LINE */
2
N/A
extern
int
_del_char
(
FORM
*);
/* REQ_DEL_CHAR */
2
N/A
extern
int
_del_prev
(
FORM
*);
/* REQ_DEL_PREV */
2
N/A
extern
int
_del_line
(
FORM
*);
/* REQ_DEL_LINE */
2
N/A
extern
int
_del_word
(
FORM
*);
/* REQ_DEL_WORD */
2
N/A
extern
int
_clr_eol
(
FORM
*);
/* REQ_CLR_EOL */
2
N/A
extern
int
_clr_eof
(
FORM
*);
/* REQ_CLR_EOF */
2
N/A
extern
int
_clr_field
(
FORM
*);
/* REQ_CLR_FIELD */
2
N/A
extern
int
_ovl_mode
(
FORM
*);
/* REQ_OVL_MODE */
2
N/A
extern
int
_ins_mode
(
FORM
*);
/* REQ_INS_MODE */
2
N/A
extern
int
_scr_fline
(
FORM
*);
/* REQ_SCR_FLINE */
2
N/A
extern
int
_scr_bline
(
FORM
*);
/* REQ_SCR_BLINE */
2
N/A
extern
int
_scr_fpage
(
FORM
*);
/* REQ_SCR_FPAGE */
2
N/A
extern
int
_scr_fhpage
(
FORM
*);
/* REQ_SCR_FHPAGE */
2
N/A
extern
int
_scr_bpage
(
FORM
*);
/* REQ_SCR_BPAGE */
2
N/A
extern
int
_scr_bhpage
(
FORM
*);
/* REQ_SCR_BHPAGE */
2
N/A
2
N/A
extern
int
_scr_fchar
(
FORM
*);
/* REQ_SCR_FCHAR */
2
N/A
extern
int
_scr_bchar
(
FORM
*);
/* REQ_SCR_BCHAR */
2
N/A
extern
int
_scr_hfline
(
FORM
*);
/* REQ_SCR_HFLINE */
2
N/A
extern
int
_scr_hbline
(
FORM
*);
/* REQ_SCR_HBLINE */
2
N/A
extern
int
_scr_hfhalf
(
FORM
*);
/* REQ_SCR_HFHALF */
2
N/A
extern
int
_scr_hbhalf
(
FORM
*);
/* REQ_SCR_HBHALF */
2
N/A
2
N/A
extern
int
_validation
(
FORM
*);
/* REQ_VALIDATION */
2
N/A
extern
int
_next_choice
(
FORM
*);
/* REQ_NEXT_CHOICE */
2
N/A
extern
int
_prev_choice
(
FORM
*);
/* REQ_PREV_CHOICE */
2
N/A
2
N/A
extern
char
*
_makearg
(
FIELDTYPE
*,
va_list
*,
int
*);
2
N/A
extern
char
*
_copyarg
(
FIELDTYPE
*,
char
*,
int
*);
2
N/A
extern
void
_freearg
(
FIELDTYPE
*,
char
*);
2
N/A
extern
int
_checkfield
(
FIELDTYPE
*,
FIELD
*,
char
*);
2
N/A
extern
int
_checkchar
(
FIELDTYPE
*,
int
,
char
*);
2
N/A
extern
int
_nextchoice
(
FIELDTYPE
*,
FIELD
*,
char
*);
2
N/A
extern
int
_prevchoice
(
FIELDTYPE
*,
FIELD
*,
char
*);
2
N/A
2
N/A
extern
BOOLEAN
_grow_field
(
FIELD
*,
int
);
2
N/A
extern
FIELD
*
_first_active
(
FORM
*);
2
N/A
extern
char
*
_data_beg
(
char
*,
int
);
2
N/A
extern
char
*
_data_end
(
char
*,
int
);
2
N/A
extern
char
*
_whsp_beg
(
char
*,
int
);
2
N/A
extern
char
*
_whsp_end
(
char
*,
int
);
2
N/A
extern
void
_buf_to_win
(
FIELD
*,
WINDOW
*);
2
N/A
extern
void
_win_to_buf
(
WINDOW
*,
FIELD
*);
2
N/A
extern
void
_adjust_cursor
(
FORM
*,
char
*);
2
N/A
extern
void
_sync_buffer
(
FORM
*);
2
N/A
extern
int
_sync_linked
(
FIELD
*);
2
N/A
extern
int
_sync_field
(
FIELD
*);
2
N/A
extern
int
_sync_attrs
(
FIELD
*);
2
N/A
extern
int
_sync_opts
(
FIELD
*,
OPTIONS
);
2
N/A
extern
int
_validate
(
FORM
*);
2
N/A
extern
int
_set_current_field
(
FORM
*,
FIELD
*);
2
N/A
extern
int
_set_form_page
(
FORM
*,
int
,
FIELD
*);
2
N/A
extern
int
_pos_form_cursor
(
FORM
*);
2
N/A
extern
int
_update_current
(
FORM
*);
2
N/A
extern
int
_data_entry
(
FORM
*,
int
);
2
N/A
extern
int
_page_navigation
(
PTF_int
,
FORM
*);
2
N/A
extern
int
_field_navigation
(
PTF_int
,
FORM
*);
2
N/A
extern
int
_data_navigation
(
PTF_int
,
FORM
*);
2
N/A
extern
int
_data_manipulation
(
PTF_int
,
FORM
*);
2
N/A
extern
int
_misc_request
(
PTF_int
,
FORM
*);
2
N/A
2
N/A
extern
intptr_t
__execute
(
char
*,
char
*);
2
N/A
extern
intptr_t
__advance
(
char
*,
char
*);
2
N/A
extern
intptr_t
__xpop
(
intptr_t
);
2
N/A
extern
intptr_t
__xpush
(
intptr_t
,
char
*);
2
N/A
extern
intptr_t
__getrnge
(
intptr_t
*,
intptr_t
*,
char
*);
2
N/A
extern
intptr_t
__cclass
(
char
*,
char
,
intptr_t
);
2
N/A
extern
int
__size
(
char
*);
2
N/A
extern
int
__rpush
(
char
*);
2
N/A
extern
intptr_t
__rpop
(
void
);
2
N/A
2
N/A
#
ifdef
__cplusplus
2
N/A
}
2
N/A
#
endif
2
N/A
2
N/A
#
endif
/* _UTILITY_H */