The following functions convert Prolog terms to C. If a Prolog term does not have the expected type, then the global C variable exception is set. A C program that uses these functions must check whether exception is set, in order to determine whether data have correctly been converted. The converted data are only correct when exception is NULL.
- int bp_get_integer(TERM t):
Converts the Prolog integer t into C. bp_is_integer(t) must be true; otherwise 0 is returned, and exception is set to integer_expected.
- double bp_get_float(TERM t):
Converts the Prolog float t into C. bp_is_float(t) must be true; otherwise exception is set to number_expected, and 0.0 is returned. This function must be declared before any use.
- (char *) bp_get_name(TERM t):
Returns a pointer to the string that is the name of term t. Either bp_is_atom(t) must be true, or bp_is_structure(t) must be true; otherwise, exception is set to illegal_arguments, and NULL is returned. This function must be declared before any use.
- int bp_get_arity(TERM t):
Returns the arity of term t. Either bp_is_atom(t) must be true, or bp_is_structure(t) must be true; otherwise, 0 is returned, and exception is set to illegal_arguments.
Neng-Fa Zhou
2013-01-25