Programming Guide |
Installs application event functions
fnc_data_r *sm_install(int func_type, fnc_data_t funcs[], int *num_fncs);
func_type
- Specifies the event function type. For event function types, refer to Table 44-1 in Application Development Guide.
funcs
- The address of the
fnc_data
structure or array of structures to install. Functions to install withsm_install
are stored in afnc_data
structure before installation. For more information aboutfnc_data
structures, refer to "Preparing Functions for Installation" in Application Development Guide.To deinstall functions, set
funcs
to 0. This removes all unprotected event functions of allfunc_type
types.num_fncs
- Supply one of these arguments:
C only
- · When installing an automatic event with a single function, returns the address of a buffer that contains a copy of the previously installed function's data structure. If no function was previously installed, returns zero.
- · When installing a function list, returns a pointer to the list.
sm_install
is typically used when you build a Panther application or authoring executable. It compiles C functions and links them to Panther's function events. These C functions can be Panther library functions or functions that you write.sm_install
can also install and deinstall functions at runtime.The file
funclist.c
, provided in source form with Panther, can be used as a template for installing automatic and demand event functions. This file contains samplefnc_data
structure definitions and corresponding calls tosm_install
. Most of these calls are used to install dummy functions to the local function lists. Replace these with your own installations.Note that in
funclist.c
, calls tosm_install
are made bysm_do_uinstalls
.sm_do_uinstalls
is called aftersm_initcrt
, which calls the initialization event functions. Consequently, you should not install an initialization event function withfunclist.c
.For specific examples of event function installation, refer to Chapter 44, "Installed Event Functions," in Application Development Guide.
/* Include the functions in fnc_data structures */
/* Install two prototyped functions that return ints,
dereference JPL-supplied variables, and take two int
arguments. */
fnc_data_t proto_list[] = {
SM_INTFNC("mark_fields(i,i)", mark_flds),
SM_INTFNC("report(s,s)", report)
};
/* Install a screen function that returns an int, does
not perform dereferencing on JPL-supplied variables,
and takes two string arguments. */
fnc_data_t autosc_struct = SM_OLDFNC(0, auto_sfunc);
/* Install the functions */
int ct = sizeof(proto_list) / sizeof(fnc_data_t);
sm_install(PROTO_FUNC, proto_list, &ct);
sm_install(DFLT_SCREEN_FUNC, &autosc_struct, (int *)0);