The following functions convert Prolog terms to C. If a Prolog term is not of the expected type, then the global C variable exception is set. A C program that uses these functions must check whether exception is set to see whether data are converted correctly. The converted data are correct only when exception is NULL.
- int bp_get_integer(TERM t):
Convert the Prolog integer t into C. bp_is_integer(t) must be true; otherwise 0 is returned before exception is set to integer_expected.
- double bp_get_float(TERM t):
Convert 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):
Return a pointer to the string that is the name of term t. Either bp_is_atom(t) 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):
Return the arity of term t. Either bp_is_atom(t) or bp_is_structure(t) must be true; otherwise, 0 is returned with exception being set to illegal_arguments.
Neng-Fa Zhou
2012-01-03