Kenwood HP 9000 Personal Computer User Manual


 
236 Chapter 6
Shared Library Management Routines
The shl_load Shared Library Management Routines
type The type of symbol you want to display. This is the
same as the type parameter to shl_getsymbols and
can have these values: TYPE_PROCEDURE, TYPE_DATA,
or TYPE_UNDEFINED. If it is TYPE_UNDEFINED,
show_symbols displays the type of each symbol.
flags This is the same as the flags parameter. It can have the
value EXPORT_SYMBOLS or IMPORT_SYMBOLS. In
addition, it can be ORed with NO_VALUES or
GLOBAL_VALUES. If EXPORT_SYMBOLS is specified
without being ORed with NO_VALUES, show_symbols
displays the address of each symbol.
show_symbols — Display Shared Library Symbols
#include <dl.h>
#include <stdio.h>
#include <stdlib.h>
int show_symbols(shl_t hndl,
short type,
int flags)
{
int num_symbols, sym_idx;
struct shl_symbol *symbols, *orig_symbols;
num_symbols = shl_getsymbols(hndl, type, flags, malloc,
&symbols);
if (num_symbols < 0) {
printf(“shl_getsymbols failed\n”);
exit(1);
}
orig_symbols = symbols;
for (sym_idx = 0; sym_idx < num_symbols; sym_idx++)
{
printf(“ %-30s”, symbols->name); /* display symbol name */
if (type == TYPE_UNDEFINED) /* display type if TYPE_UNDEFINED */
switch (symbols->type) {
case TYPE_PROCEDURE:
printf(“ PROCEDURE”);
break;
case TYPE_DATA:
printf(“ DATA “);
break;
case TYPE_STORAGE:
printf(“ STORAGE “);
}
if ((flags & EXPORT_SYMBOLS) /* export symbols requested
*/
&& (flags & NO_VALUES)==0) /* NO_VALUES was NOT
specified */
printf(“ 0x%8X”, symbols->value); /* so display symbol’s
address */
printf(“\n”); /* terminate output line
*/
symbols++; /* move to next symbol record