libicl.c File Reference

Contains C versions of ICL constructor and accessor routines. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <ctype.h>
#include "libicl.h"
#include "libutils.h"
#include "libicl_private.h"
#include "libicl_depr.h"
#include "stdpccts.h"

Go to the source code of this file.

Data Structures

struct  compoundInfo_s
struct  CompoundInfo
struct  CompoundStructType
struct  CompoundListType
struct  CompoundGroupType
struct  CompoundSentinelType

Defines

#define EXPORT_BORLAND
#define EXPORT_MSCPP
#define STREQ(str1, str2)   (strcmp((str1), (str2)) == 0)

Typedefs

typedef compoundInfo_s compoundInfo_t

Enumerations

enum  CompoundType { compound_sentinel_type, compound_struct_type, compound_list_type, compound_group_type }

Functions

EXTERN void printDebug (int level, char *str,...)
 Prints out debug messages.
int iclDecRef (ICLTerm *t)
 Decrement the reference count of a term.
EXPORT_MSCPP void EXPORT_BORLAND icl_init_const_dyn_array (struct const_dyn_array *da)
 Initializes a const dynamic array.
EXPORT_MSCPP void EXPORT_BORLAND icl_init_dyn_array (struct dyn_array *da)
 Initializes a dynamic array.
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsVar (char *t)
 Returns TRUE if the term is a variable.
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsOperation (char *t)
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsIclDataQ (char *t, size_t len)
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsInt (char *t)
 Returns TRUE if the term is an integer.
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsFloat (char *t)
 Returns TRUE if the term is a float.
EXPORT_MSCPP void EXPORT_BORLAND icl_stUndoubleQuotes (char *s)
 Converts any '' marks inside a string to just '.
EXPORT_MSCPP char *EXPORT_BORLAND icl_stFixQuotes (char *s)
 Converts any '' marks inside a string to just ', and removes any external quote marks around the string.
EXPORT_MSCPP char *EXPORT_BORLAND icl_stDoubleQuotes (char *s)
 Doubles any "'" in the string, to prepare the string to be surrounded by "'".
EXPORT_MSCPP char *EXPORT_BORLAND icl_stQuoteForce (char *s)
 Adjusts the quotes in a string to be a legal ICL Str.
EXPORT_MSCPP char *EXPORT_BORLAND icl_stQuote (char *s)
 Adjusts the quotes in a string to be a legal ICL Str.
EXPORT_MSCPP void EXPORT_BORLAND icl_stTrim (char *s)
 Removes leading and trailing spaces and other unprintables.
EXPORT_MSCPP void EXPORT_BORLAND icl_stAppend (char **str1, char *str2)
 Appends a string onto the end of a first one, adjusting the size of the resulting string if necessary.
compoundInfo_tcompoundInfo_new ()
int compoundInfo_finished (compoundInfo_t *ci)
void compoundInfo_setNumChildren (compoundInfo_t *ci, int n)
int compoundInfo_getCurrentChildNum (compoundInfo_t *ci)
void compoundInfo_setPreAllButFirst (compoundInfo_t *ci, guint8 *s, size_t len)
void compoundInfo_setPostAllButLast (compoundInfo_t *ci, guint8 *s, size_t len)
void compoundInfo_setPreChild (compoundInfo_t *ci, guint8 *s, size_t len)
void compoundInfo_setPostChild (compoundInfo_t *ci, guint8 *s, size_t len)
void compoundInfo_setPostPend (compoundInfo_t *ci, guint8 *s, size_t len)
guint8 * compoundInfo_getPreChild (compoundInfo_t *ci, int i, size_t *len)
guint8 * compoundInfo_getPostChild (compoundInfo_t *ci, int i, size_t *len)
guint8 * compoundInfo_getPostPend (compoundInfo_t *ci, size_t *len)
void compoundInfo_childFinished (compoundInfo_t *ci)
int icl_toWireString (ICLTerm *t, char **termAsString, size_t *termAsStringLen)
 You must free termAsString when you are done with it.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewTermFromData (char *data, size_t len)
 Create a new IclTerm from the given data.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewTermFromString (char *t)
 Returns a pointer to a new structured Icl term given string containing an ICL expression, or NULL if a valid object could not be created.
EXPORT_MSCPP char *EXPORT_BORLAND icl_NewStringFromTerm (ICLTerm const *t)
 Creates a string representation from an ICL term.
EXPORT_MSCPP char *EXPORT_BORLAND icl_UnquotedStringFromStr (ICLTerm *t)
 Get an unquoted string from an IclStr.
EXPORT_MSCPP char *EXPORT_BORLAND icl_ForcedQuotedStringFromStr (ICLTerm *t)
 Get a string from an IclStr, quoting it even if the quotes are not necessary.
EXPORT_MSCPP char *EXPORT_BORLAND icl_MinimallyQuotedStringFromStr (ICLTerm *t)
 Get a minimally quoted string from an IclStr.
EXPORT_MSCPP char *EXPORT_BORLAND pt (ICLTerm *t)
EXPORT_MSCPP char *EXPORT_BORLAND icl_NewStringStructFromTerm (ICLTerm *t)
 Creates a string representation from an ICL term.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_copy_term_nonrec (ICLTerm const *t, struct dyn_array *vars)
 Creates a copy of the term, all in new memory.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_CopyTerm (ICLTerm const *t)
 Creates a copy of the term, all in new memory.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_CopyListType (ICLListType *list)
 Creates a new copy of a ListType list.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewInt (gint64 i)
 Creates a new ICL object of type integer.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewFloat (double f)
 Creates a new ICL object of type float.
EXPORT_MSCPP int EXPORT_BORLAND icl_stIsProperlyQuoted (char *s)
 return TRUE if the given string is properly quoted
void icl_setStrFromProperlyQuoted (char *s, ICLTerm *res)
 Assumes we are given s, which we can modify.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewStr (char const *s)
 Creates a new ICL object of type string.
ICLTermicl_NewStrNoCopy (char *s)
 Creates a new ICL object of type string.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewVar (char *name)
 Creates a new ICL object of type variable.
ICLTermicl_NewVarNoCopy (char *name)
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewStructFromList (char const *functor, ICLTerm *args)
 Creates a new ICL object of type structure given args as a list.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewStruct (char const *functor, int arity,...)
 Creates a new ICL object of type structure.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_NewCons (ICLTerm *elt, ICLListType *tail)
 Returns a new element of ICLListType.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewDataQ (void const *data, size_t dataLen)
ICLTermicl_NewDataQNoCopy (void *data, size_t dataLen)
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewGroup (char startC, char *separator, ICLListType *list)
 Creates a new ICL object of type group.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NewList (ICLListType *list)
 Creates a new ICL object of type list.
EXPORT_MSCPP void EXPORT_BORLAND icl_FreeTermSingle (ICLTerm *elt)
EXPORT_MSCPP void EXPORT_BORLAND icl_FreeTerm (ICLTerm *elt)
EXPORT_MSCPP void EXPORT_BORLAND icl_stFree (void *p)
 Free a memory pointer (string or term) and set it to NULL afterwards.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsList (ICLTerm const *elt)
 Returns TRUE if object is of type List.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsGroup (ICLTerm const *elt)
 Returns TRUE if object is of type Group.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsStruct (ICLTerm const *elt)
 Returns TRUE if object is of type Struct.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsStr (ICLTerm const *elt)
 Returns TRUE if object is of type Str.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsVar (ICLTerm const *elt)
 Returns TRUE if object is of type Var.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsInt (ICLTerm const *elt)
 Returns TRUE if object is of type Int.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsFloat (ICLTerm const *elt)
 Returns TRUE if object is of type Float.
EXPORT_MSCPP int EXPORT_BORLAND icl_IsDataQ (ICLTerm const *elt)
EXPORT_MSCPP int EXPORT_BORLAND icl_IsValid (ICLTerm const *elt)
 Returns TRUE if object is valid.
int icl_IsGround (ICLTerm const *term)
EXPORT_MSCPP void *EXPORT_BORLAND icl_DataQ (ICLTerm const *elt)
 Get the data associated with this ICLTerm if it is of type icl_dataq_type.
EXPORT_MSCPP size_t EXPORT_BORLAND icl_DataQLen (ICLTerm const *elt)
EXPORT_MSCPP size_t EXPORT_BORLAND icl_Len (ICLTerm const *elt)
 Returns 0 if invalid.
EXPORT_MSCPP gint64 EXPORT_BORLAND icl_Int (ICLTerm const *elt)
 Returns the value for an ICL int.
EXPORT_MSCPP double EXPORT_BORLAND icl_Float (ICLTerm const *elt)
 Returns the value for an ICL float.
EXPORT_MSCPP char *EXPORT_BORLAND icl_Str (ICLTerm const *elt)
 Returns the value for an ICL str (minimally quoted), struct (functor), or an ICL var (returns name).
EXPORT_MSCPP char *EXPORT_BORLAND icl_Functor (ICLTerm const *elt)
 Returns the functor for an ICL struct.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_Arguments (ICLTerm const *elt)
 Returns a pointer to the list of arguments for an ICL structure.
EXPORT_MSCPP int EXPORT_BORLAND icl_GetGroupChars (ICLTerm const *group, char *startC, char **sep)
 Returns the start character and separators for a group.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_List (ICLTerm const *elt)
 Returns a pointer to the list of elements for an ICL list.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_ListNext (ICLListType const *t)
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_ListElt (ICLListType const *t)
ICLListTypeicl_copy_listtype (ICLListType *l)
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_ListCopy (ICLTerm const *elt)
 Returns a pointer to the list of elements for an ICL list.
EXPORT_MSCPP int EXPORT_BORLAND icl_AddToList (ICLTerm *list, ICLTerm *elt, int atEnd)
 Adds an object at the beginning or the end of the list or a group.
EXPORT_MSCPP int EXPORT_BORLAND icl_ClearList (ICLTerm *list)
 Removes all the components of the incoming list.
EXPORT_MSCPP int EXPORT_BORLAND icl_SortList (ICLTerm *list, int(*user_function)(ICLTerm *Elt1, ICLTerm *Elt2))
 Sorts the incoming list, using the given sorting function.
EXPORT_MSCPP int EXPORT_BORLAND icl_ListHasMoreElements (ICLListType const *l)
 Determine if you have iterated to the end of a list.
EXPORT_MSCPP ICLListType
*EXPORT_BORLAND 
icl_ListNextElement (ICLListType const *l)
 Return the next element in a list.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_ListElement (ICLListType const *list)
 Return the icl term associated with this list element.
EXPORT_MSCPP int EXPORT_BORLAND icl_ListDelete (ICLTerm *list, ICLTerm *elem, ICLTerm **residue)
 Return TRUE if list is a list.
EXPORT_MSCPP int EXPORT_BORLAND icl_AppendCopy (ICLTerm *list1, ICLTerm const *list2)
 Append a copy of list2 to the end of list1.
EXPORT_MSCPP int EXPORT_BORLAND icl_Append (ICLTerm *list1, ICLTerm *list2)
 Append list2 to the end of list1.
EXPORT_MSCPP int EXPORT_BORLAND icl_Union (ICLTerm *list1, ICLTerm *list2, ICLTerm **dest)
 Merges two incoming lists into a third one.
EXPORT_MSCPP int EXPORT_BORLAND icl_Arity (ICLTerm const *elt)
 Return the arity of an incoming term.
EXPORT_MSCPP int EXPORT_BORLAND icl_NumTerms (ICLTerm const *elt)
 Returns the number of terms in a list (or group) object, or the number of arguments in a structure.
EXPORT_MSCPP int EXPORT_BORLAND icl_ListLen (ICLTerm const *elt)
 Returns the number of terms in a list (or group) object, or the number of arguments in a structure.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_NthTerm (ICLTerm const *elt, int n)
 Returns a pointer to the Nth argument in a structure, or the Nth element of a list or of a group.
EXPORT_MSCPP int EXPORT_BORLAND icl_NthTermAsInt (ICLTerm const *elt, int n, int *Value)
 Returns the integer value of the nth element in a term.
EXPORT_MSCPP int EXPORT_BORLAND icl_ParamValue (char *func, ICLTerm *match, ICLTerm *paramlist, ICLTerm **value)
 Searches for a parameter in a parameter list.
EXPORT_MSCPP gint64 EXPORT_BORLAND icl_ParamValueAsInt (char *func, ICLTerm *paramlist, gint64 *Value)
 Returns integer value for a parameter in a parameter list.
EXPORT_MSCPP int EXPORT_BORLAND icl_Member (ICLTerm const *elt, ICLTerm const *list, ICLTerm **res)
 Searches for an element in a list, returning unification.
EXPORT_MSCPP int EXPORT_BORLAND icl_match_terms (ICLTerm *t1, ICLTerm *t2, struct dyn_array *vars)
 Returns TRUE if Term1 matches Term2, saving variable bindings as it goes (if requested).
EXPORT_MSCPP int EXPORT_BORLAND icl_match_terms_DEBUG (ICLTerm *t1, ICLTerm *t2, struct dyn_array *vars)
EXPORT_MSCPP int EXPORT_BORLAND icl_Unify (ICLTerm const *t1, ICLTerm const *t2, ICLTerm **answer)
 Perform true unification and return resulting term.
EXPORT_MSCPP int EXPORT_BORLAND icl_Unify_DEBUG (ICLTerm *t1, ICLTerm *t2, ICLTerm **answer)
EXPORT_MSCPP int EXPORT_BORLAND icl_WriteTerm (ICLTerm *t)
 Writes a term to standard out.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_True ()
 Convenience functions which return a pointer to a commonly used datastructure.
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_False ()
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_Empty ()
EXPORT_MSCPP ICLTerm *EXPORT_BORLAND icl_Var ()
int icl_list_has_more_elements (ICLListType *l)
 Determine if you have iterated to the end of a list.
ICLListTypeicl_list_next_element (ICLListType *l)
 Return the next element in a list.
ICLTermicl_list_element (ICLListType *list)
 Return the icl term associated with this list element.
int icl_list_delete (ICLTerm *list, ICLTerm *elem, ICLTerm **residue)
 Return TRUE if list is a list.
int icl_append_to_list (ICLTerm *list1, ICLTerm *list2, ICLTerm **list3)
 Append list2 to the end of list1 and place the results in list3.
EXPORT_MSCPP ICLTermicl_GenerateSimpleUnifyingTerm (ICLTerm const *term)
 Generate a general unifying term for the given term.
EXPORT_MSCPP int icl_ReplaceElement (ICLTerm *term, int index, ICLTerm *replacement, int freeReplaced)
 Replace the element at the given index with the replacement term.
EXPORT_MSCPP int icl_ReplaceUnifying (ICLTerm *term, ICLTerm const *selector, ICLTerm const *replacement, int freeReplaced)
 Replace elements that unify with the selector with the replacement term.

Variables

char * ICLDATAQSTART
size_t ICLDATAQSTARTLEN


Detailed Description

Contains C versions of ICL constructor and accessor routines.

Definition in file libicl.c.


Define Documentation

#define EXPORT_BORLAND

Definition at line 27 of file libicl.c.

#define EXPORT_MSCPP

Definition at line 32 of file libicl.c.

#define STREQ ( str1,
str2   )     (strcmp((str1), (str2)) == 0)

Definition at line 72 of file libicl.c.


Typedef Documentation

typedef struct compoundInfo_s compoundInfo_t

Definition at line 612 of file libicl.c.


Enumeration Type Documentation

enum CompoundType

Enumerator:
compound_sentinel_type 
compound_struct_type 
compound_list_type 
compound_group_type 

Definition at line 1352 of file libicl.c.


Function Documentation

void compoundInfo_childFinished ( compoundInfo_t ci  ) 

Definition at line 714 of file libicl.c.

int compoundInfo_finished ( compoundInfo_t ci  ) 

Definition at line 621 of file libicl.c.

int compoundInfo_getCurrentChildNum ( compoundInfo_t ci  ) 

Definition at line 637 of file libicl.c.

guint8* compoundInfo_getPostChild ( compoundInfo_t ci,
int  i,
size_t *  len 
)

Definition at line 690 of file libicl.c.

guint8* compoundInfo_getPostPend ( compoundInfo_t ci,
size_t *  len 
)

Definition at line 708 of file libicl.c.

guint8* compoundInfo_getPreChild ( compoundInfo_t ci,
int  i,
size_t *  len 
)

Definition at line 672 of file libicl.c.

compoundInfo_t* compoundInfo_new (  ) 

Definition at line 614 of file libicl.c.

void compoundInfo_setNumChildren ( compoundInfo_t ci,
int  n 
)

Definition at line 631 of file libicl.c.

void compoundInfo_setPostAllButLast ( compoundInfo_t ci,
guint8 *  s,
size_t  len 
)

Definition at line 648 of file libicl.c.

void compoundInfo_setPostChild ( compoundInfo_t ci,
guint8 *  s,
size_t  len 
)

Definition at line 660 of file libicl.c.

void compoundInfo_setPostPend ( compoundInfo_t ci,
guint8 *  s,
size_t  len 
)

Definition at line 666 of file libicl.c.

void compoundInfo_setPreAllButFirst ( compoundInfo_t ci,
guint8 *  s,
size_t  len 
)

Definition at line 642 of file libicl.c.

void compoundInfo_setPreChild ( compoundInfo_t ci,
guint8 *  s,
size_t  len 
)

Definition at line 654 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_AddToList ( ICLTerm list,
ICLTerm elt,
int  atEnd 
)

Adds an object at the beginning or the end of the list or a group.

Returns:
TRUE if the object can be added

Definition at line 2820 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Append ( ICLTerm list1,
ICLTerm list2 
)

Append list2 to the end of list1.

Definition at line 2981 of file libicl.c.

int icl_append_to_list ( ICLTerm list1,
ICLTerm list2,
ICLTerm **  list3 
)

Append list2 to the end of list1 and place the results in list3.

Definition at line 3746 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_AppendCopy ( ICLTerm list1,
ICLTerm const *  list2 
)

Append a copy of list2 to the end of list1.

Definition at line 2960 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_Arguments ( ICLTerm const *  elt  ) 

Returns a pointer to the list of arguments for an ICL structure.

If not valid, returns NULL.

Definition at line 2692 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Arity ( ICLTerm const *  elt  ) 

Return the arity of an incoming term.

Parameters:
elt the incoming term
Returns:
the arity of elt, or -1 for elements which are not lists, groups or structs

Definition at line 3035 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_ClearList ( ICLTerm list  ) 

Removes all the components of the incoming list.

Returns:
TRUE if successful

Definition at line 2862 of file libicl.c.

ICLListType* icl_copy_listtype ( ICLListType l  ) 

Definition at line 2763 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_copy_term_nonrec ( ICLTerm const *  t,
struct dyn_array *  vars 
)

Creates a copy of the term, all in new memory.

Deref vars from binding list if available. Nonrecursive.

Definition at line 1451 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_CopyListType ( ICLListType list  ) 

Creates a new copy of a ListType list.

Definition at line 1735 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_CopyTerm ( ICLTerm const *  t  ) 

Creates a copy of the term, all in new memory.

Definition at line 1724 of file libicl.c.

EXPORT_MSCPP void* EXPORT_BORLAND icl_DataQ ( ICLTerm const *  elt  ) 

Get the data associated with this ICLTerm if it is of type icl_dataq_type.

Returns:
a pointer to the data, or NULL
See also:
icl_dataq_type

Definition at line 2573 of file libicl.c.

EXPORT_MSCPP size_t EXPORT_BORLAND icl_DataQLen ( ICLTerm const *  elt  ) 

Definition at line 2585 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_Empty (  ) 

Definition at line 3655 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_False (  ) 

Definition at line 3641 of file libicl.c.

EXPORT_MSCPP double EXPORT_BORLAND icl_Float ( ICLTerm const *  elt  ) 

Returns the value for an ICL float.

If not valid, returns 0.0.

Definition at line 2634 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_ForcedQuotedStringFromStr ( ICLTerm t  ) 

Get a string from an IclStr, quoting it even if the quotes are not necessary.

The newly created string should be freed with icl_stFree(...)

Returns:
the new string or NULL if t is not an atom

Definition at line 1185 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_FreeTerm ( ICLTerm elt  ) 

Definition at line 2265 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_FreeTermSingle ( ICLTerm elt  ) 

Definition at line 2257 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_Functor ( ICLTerm const *  elt  ) 

Returns the functor for an ICL struct.

If not valid, returns NULL. Otherwise returns a pointer to the true string value, which should not be deallocated or changed!!!

Definition at line 2674 of file libicl.c.

EXPORT_MSCPP ICLTerm* icl_GenerateSimpleUnifyingTerm ( ICLTerm const *  term  ) 

Generate a general unifying term for the given term.

Returns:
ICLTerm* a term that unifies with the given one. Must be freed using icl_FreeTerm(ICLTerm*)

Definition at line 3771 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_GetGroupChars ( ICLTerm const *  group,
char *  startC,
char **  sep 
)

Returns the start character and separators for a group.

If not valid group, returns FALSE.

example:

   {a ; b ; c}  returns '{' and ";"
 

Definition at line 2711 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_init_const_dyn_array ( struct const_dyn_array *  da  ) 

Initializes a const dynamic array.

Definition at line 133 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_init_dyn_array ( struct dyn_array *  da  ) 

Initializes a dynamic array.

Definition at line 143 of file libicl.c.

EXPORT_MSCPP gint64 EXPORT_BORLAND icl_Int ( ICLTerm const *  elt  ) 

Returns the value for an ICL int.

If not valid, returns 0.

Definition at line 2616 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsDataQ ( ICLTerm const *  elt  ) 

Definition at line 2516 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsFloat ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Float.

Definition at line 2509 of file libicl.c.

int icl_IsGround ( ICLTerm const *  term  ) 

Definition at line 2537 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsGroup ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Group.

Definition at line 2455 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsInt ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Int.

Definition at line 2498 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsList ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type List.

Definition at line 2445 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsStr ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Str.

Definition at line 2476 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsStruct ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Struct.

Definition at line 2465 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsValid ( ICLTerm const *  elt  ) 

Returns TRUE if object is valid.

Definition at line 2527 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_IsVar ( ICLTerm const *  elt  ) 

Returns TRUE if object is of type Var.

Definition at line 2487 of file libicl.c.

EXPORT_MSCPP size_t EXPORT_BORLAND icl_Len ( ICLTerm const *  elt  ) 

Returns 0 if invalid.

Definition at line 2600 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_List ( ICLTerm const *  elt  ) 

Returns a pointer to the list of elements for an ICL list.

If not valid, returns NULL. Also works for an icl_Struct (equivalent to icl_Arguments) or an icl_Group.

Definition at line 2730 of file libicl.c.

int icl_list_delete ( ICLTerm list,
ICLTerm elem,
ICLTerm **  residue 
)

Return TRUE if list is a list.

Residue is list with all the elements that unify with elem removed.

Definition at line 3726 of file libicl.c.

ICLTerm* icl_list_element ( ICLListType list  ) 

Return the icl term associated with this list element.

Definition at line 3717 of file libicl.c.

int icl_list_has_more_elements ( ICLListType l  ) 

Determine if you have iterated to the end of a list.

Definition at line 3696 of file libicl.c.

ICLListType* icl_list_next_element ( ICLListType l  ) 

Return the next element in a list.

Definition at line 3706 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_ListCopy ( ICLTerm const *  elt  ) 

Returns a pointer to the list of elements for an ICL list.

If not valid, returns NULL. Also works for an icl_Struct (equivalent to icl_Arguments) or an icl_Group.

Definition at line 2787 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_ListDelete ( ICLTerm list,
ICLTerm elem,
ICLTerm **  residue 
)

Return TRUE if list is a list.

Residue is list with all the elements that unify with elem removed. Residue will contain entirely new memory

Definition at line 2939 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_ListElement ( ICLListType const *  list  ) 

Return the icl term associated with this list element.

Definition at line 2927 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_ListElt ( ICLListType const *  t  ) 

Definition at line 2757 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_ListHasMoreElements ( ICLListType const *  l  ) 

Determine if you have iterated to the end of a list.

Definition at line 2900 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_ListLen ( ICLTerm const *  elt  ) 

Returns the number of terms in a list (or group) object, or the number of arguments in a structure.

Returns 0 for elements which are not lists, groups or structs. Same as icl_NumTerms; convenience function for lists.

Definition at line 3073 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_ListNext ( ICLListType const *  t  ) 

Definition at line 2751 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_ListNextElement ( ICLListType const *  l  ) 

Return the next element in a list.

Definition at line 2914 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_match_terms ( ICLTerm t1,
ICLTerm t2,
struct dyn_array *  vars 
)

Returns TRUE if Term1 matches Term2, saving variable bindings as it goes (if requested).

Parameters:
t1 term to match (unify)
t2 term to match (unify)
vars a list where variable bindings will be stored during unification. If vars is NULL, no var bindings are kept, acting as a simple match instead of a true unify.
Returns:
the stringlist of vars/bindings which must be deallocated when finished (free_dyn_list)

Definition at line 3323 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_match_terms_DEBUG ( ICLTerm t1,
ICLTerm t2,
struct dyn_array *  vars 
)

Definition at line 3400 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Member ( ICLTerm const *  elt,
ICLTerm const *  list,
ICLTerm **  res 
)

Searches for an element in a list, returning unification.

Returns:
TRUE if successful, FALSE otherwise (doesn't change res). If res is NULL, just returns TRUE if element was found

Definition at line 3233 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_MinimallyQuotedStringFromStr ( ICLTerm t  ) 

Get a minimally quoted string from an IclStr.

The newly created string should be freed with icl_stFree(...). This is equivalent to calling icl_NewStringFromTerm(t), but is named consistently with the other quoted string functions.

Returns:
the new string or NULL if t is not an atom

Definition at line 1196 of file libicl.c.

EXPORT_MSCPP ICLListType* EXPORT_BORLAND icl_NewCons ( ICLTerm elt,
ICLListType tail 
)

Returns a new element of ICLListType.

Definition at line 2152 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewDataQ ( void const *  data,
size_t  dataLen 
)

Definition at line 2167 of file libicl.c.

ICLTerm* icl_NewDataQNoCopy ( void *  data,
size_t  dataLen 
)

Definition at line 2188 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewFloat ( double  f  ) 

Creates a new ICL object of type float.

Parameters:
f double value for the structure
Returns:
a pointer to the new ICL object

Definition at line 1774 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewGroup ( char  startC,
char *  separator,
ICLListType list 
)

Creates a new ICL object of type group.

Parameters:
startC a character which initially delimits the group (e.g. '{')
separator separator character
list a value of type list, probably returned by icl_NewCons()
Returns:
a pointer to the new ICL object
See also:
icl_NewCons

Definition at line 2212 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewInt ( gint64  i  ) 

Creates a new ICL object of type integer.

Parameters:
i integer value for the structure
Returns:
a pointer to the new ICL object

Definition at line 1749 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewList ( ICLListType list  ) 

Creates a new ICL object of type list.

Parameters:
list a value of type list, probably returned by icl_NewCons()
Returns:
a pointer to the new ICL object
See also:
icl_NewCons

Definition at line 2239 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewStr ( char const *  s  ) 

Creates a new ICL object of type string.

Uses a copy of the given string.

Parameters:
s string value for the structure
Returns:
a pointer to the new ICL object or NULL if s is not valid

Definition at line 1958 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_NewStringFromTerm ( ICLTerm const *  t  ) 

Creates a string representation from an ICL term.

The string value is created in a new space which should be icl_stFree'd when finished using.

Definition at line 1030 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_NewStringStructFromTerm ( ICLTerm t  ) 

Creates a string representation from an ICL term.

The string value is created in a new space which should be icl_stFree'd when finished using.

See also:
icl_stFree

Definition at line 1225 of file libicl.c.

ICLTerm* icl_NewStrNoCopy ( char *  s  ) 

Creates a new ICL object of type string.

Reuses the given string as the working buffer.

Definition at line 1984 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewStruct ( char const *  functor,
int  arity,
  ... 
)

Creates a new ICL object of type structure.

Uses a copy of functor.

Parameters:
functor string name for the structure
arity the new structure's arity
... a variable length argument list containing pointers to ICLTerms, owned by returned ICLTerm
Returns:
a pointer to the new ICL object or NULL if not valid args

Definition at line 2101 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewStructFromList ( char const *  functor,
ICLTerm args 
)

Creates a new ICL object of type structure given args as a list.

Parameters:
functor string name for the structure
args an icl List object; will be owned by the returned ICLTerm
Returns:
a pointer to the new ICL object or NULL if invalid args or invalid functor

Definition at line 2059 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewTermFromData ( char *  data,
size_t  len 
)

Create a new IclTerm from the given data.

Parameters:
data the data representing the term.
len the length of the data. If data is a char*, this does not include the ending '' character.

Definition at line 993 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewTermFromString ( char *  t  ) 

Returns a pointer to a new structured Icl term given string containing an ICL expression, or NULL if a valid object could not be created.

Deprecated:
Use icl_NewTermFromData() instead

Definition at line 1009 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NewVar ( char *  name  ) 

Creates a new ICL object of type variable.

Parameters:
name string value containing the name for the structure
Returns:
a pointer to the new ICL object or NULL if name isn't valid

Definition at line 2011 of file libicl.c.

ICLTerm* icl_NewVarNoCopy ( char *  name  ) 

Definition at line 2031 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_NthTerm ( ICLTerm const *  elt,
int  n 
)

Returns a pointer to the Nth argument in a structure, or the Nth element of a list or of a group.

Returns NULL if an error occurs.

Definition at line 3083 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_NthTermAsInt ( ICLTerm const *  elt,
int  n,
int *  Value 
)

Returns the integer value of the nth element in a term.

Makes a copy into Value.

Returns:
TRUE if successful, FALSE otherwise (doesn't change Value).

Definition at line 3114 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_NumTerms ( ICLTerm const *  elt  ) 

Returns the number of terms in a list (or group) object, or the number of arguments in a structure.

Returns 0 for elements which are not lists, groups or structs.

Definition at line 3047 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_ParamValue ( char *  func,
ICLTerm match,
ICLTerm paramlist,
ICLTerm **  value 
)

Searches for a parameter in a parameter list.

Examples:

   icl_ParamValue("a", ICL_EMPTY, params, NULL) : looks for "a([])"
   icl_ParamValue("a", NULL, params, &value) : returns value like a(X)
 
Parameters:
match may be NULL, or a value to unify against
value may be NULL, in which case just returns TRUE if found
Returns:
TRUE if found

Definition at line 3138 of file libicl.c.

EXPORT_MSCPP gint64 EXPORT_BORLAND icl_ParamValueAsInt ( char *  func,
ICLTerm paramlist,
gint64 *  Value 
)

Returns integer value for a parameter in a parameter list.

Returns:
TRUE if successful, FALSE otherwise (doesn't change Value)

Definition at line 3208 of file libicl.c.

EXPORT_MSCPP int icl_ReplaceElement ( ICLTerm term,
int  index,
ICLTerm replacement,
int  freeReplaced 
)

Replace the element at the given index with the replacement term.

If freeReplaced is non-zero, icl_FreeTerm(ICLTerm*) is called on the replaced term.

Takes ownership of replacement.

Definition at line 3811 of file libicl.c.

EXPORT_MSCPP int icl_ReplaceUnifying ( ICLTerm term,
ICLTerm const *  selector,
ICLTerm const *  replacement,
int  freeReplaced 
)

Replace elements that unify with the selector with the replacement term.

If freeReplaced is non-zero, icl_FreeTerm(ICLTerm*) is called on the replaced term. Uses copies of replacement. Returns the number of elements replaced.

Definition at line 3840 of file libicl.c.

void icl_setStrFromProperlyQuoted ( char *  s,
ICLTerm res 
)

Assumes we are given s, which we can modify.

Definition at line 1912 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_SortList ( ICLTerm list,
int(*)(ICLTerm *Elt1, ICLTerm *Elt2)  user_function 
)

Sorts the incoming list, using the given sorting function.

Returns:
TRUE if successful

Definition at line 2888 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_stAppend ( char **  str1,
char *  str2 
)

Appends a string onto the end of a first one, adjusting the size of the resulting string if necessary.

The memory allocation of str1 will be readjusted to be able to contain text for both str1 and str2.

Parameters:
str1 address of a string pointer, maybe containing data
str2 a string to concatenate to str1

Definition at line 493 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_stDoubleQuotes ( char *  s  ) 

Doubles any "'" in the string, to prepare the string to be surrounded by "'".

Parameters:
s a string containing prolog terms
Returns:
the string with any ' to ''. The pointer returned should not be deallocated or the contents changed in any way, just used as is. The original parameter string is not changed. Safe for icldataq since we assume s contains no icldataq() terms.

Definition at line 290 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_stFixQuotes ( char *  s  ) 

Converts any '' marks inside a string to just ', and removes any external quote marks around the string.

Calls icl_stRemoveQuotes, followed by icl_stUndoubleQuotes. should be okay for icldataq, since we assume s does not contain an icldataq.

Parameters:
s a string containing an ICL Str.
Returns:
a pointer to the original string, which has been modified appropriately.

Definition at line 269 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_stFree ( void *  p  ) 

Free a memory pointer (string or term) and set it to NULL afterwards.

Parameters:
p a variable to deallocate
Remarks:

Definition at line 2284 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsFloat ( char *  t  ) 

Returns TRUE if the term is a float.

Parameters:
t a string containing a float
Returns:
TRUE if the term is a float

Definition at line 208 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsIclDataQ ( char *  t,
size_t  len 
)

Definition at line 170 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsInt ( char *  t  ) 

Returns TRUE if the term is an integer.

Parameters:
t a string containing an integer
Returns:
TRUE if the term is a integer

Definition at line 192 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsOperation ( char *  t  ) 

Definition at line 164 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsProperlyQuoted ( char *  s  ) 

return TRUE if the given string is properly quoted

Definition at line 1833 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_stIsVar ( char *  t  ) 

Returns TRUE if the term is a variable.

Parameters:
t a string containing a prolog term (or variable)
Returns:
TRUE if the term is a variable

Definition at line 157 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_stQuote ( char *  s  ) 

Adjusts the quotes in a string to be a legal ICL Str.

If necessary, adds ' characters around the string, and doubles any internal ' chars. The original parameter string is not changed.

Parameters:
s a string
Returns:
a legal ICL Str. The pointer returned should not be deallocated or the contents changed in any way, just used as is.

Definition at line 408 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_stQuoteForce ( char *  s  ) 

Adjusts the quotes in a string to be a legal ICL Str.

If necessary, adds ' characters around the string, and doubles any internal ' chars. The original parameter string is not changed.

Parameters:
s a string
Returns:
a legal ICL Str. The pointer returned should not be deallocated or the contents changed in any way, just used as is.

Definition at line 348 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_Str ( ICLTerm const *  elt  ) 

Returns the value for an ICL str (minimally quoted), struct (functor), or an ICL var (returns name).

If not valid, returns NULL. Otherwise returns a pointer to the true string value, which should not be deallocated or changed!!!

Definition at line 2654 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_stTrim ( char *  s  ) 

Removes leading and trailing spaces and other unprintables.

Parameters:
s,: a string containing prolog terms

Definition at line 472 of file libicl.c.

EXPORT_MSCPP void EXPORT_BORLAND icl_stUndoubleQuotes ( char *  s  ) 

Converts any '' marks inside a string to just '.

Single quotes inside strings will be doubled when coming from Prolog. This is icldataq safe because it is only called on known iclStr types.

Parameters:
s a string containing prolog terms on input

Definition at line 234 of file libicl.c.

int icl_toWireString ( ICLTerm t,
char **  termAsString,
size_t *  termAsStringLen 
)

You must free termAsString when you are done with it.

Definition at line 722 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_True (  ) 

Convenience functions which return a pointer to a commonly used datastructure.

The results should not be free'd!

Definition at line 3627 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Unify ( ICLTerm const *  t1,
ICLTerm const *  t2,
ICLTerm **  answer 
)

Perform true unification and return resulting term.

Remarks

Returns:
if the two terms unify, returns TRUE and answer will contain the unified term. Otherwise returns FALSE (answer not changed).

Definition at line 3504 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Unify_DEBUG ( ICLTerm t1,
ICLTerm t2,
ICLTerm **  answer 
)

Definition at line 3550 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_Union ( ICLTerm list1,
ICLTerm list2,
ICLTerm **  dest 
)

Merges two incoming lists into a third one.

Allocates memory pointed to by *dest

Returns:
TRUE if successful.

Definition at line 3014 of file libicl.c.

EXPORT_MSCPP char* EXPORT_BORLAND icl_UnquotedStringFromStr ( ICLTerm t  ) 

Get an unquoted string from an IclStr.

The newly created string should be freed with icl_stFree(...).

Returns:
the new string or NULL if t is not an atom

Definition at line 1174 of file libicl.c.

EXPORT_MSCPP ICLTerm* EXPORT_BORLAND icl_Var (  ) 

Definition at line 3671 of file libicl.c.

EXPORT_MSCPP int EXPORT_BORLAND icl_WriteTerm ( ICLTerm t  ) 

Writes a term to standard out.

Returns:
TRUE if the term is valid and could be written

Definition at line 3603 of file libicl.c.

int iclDecRef ( ICLTerm t  ) 

Decrement the reference count of a term.

Returns:
a new reference count, which may be negative (for multiple incorrect frees).

Definition at line 120 of file libicl.c.

EXTERN void printDebug ( int  level,
char *  str,
  ... 
)

Prints out debug messages.

Definition at line 382 of file libutils.c.

EXPORT_MSCPP char* EXPORT_BORLAND pt ( ICLTerm t  ) 

Definition at line 1212 of file libicl.c.


Variable Documentation

char* ICLDATAQSTART

size_t ICLDATAQSTARTLEN


Generated on Wed May 23 17:20:14 2007 using doxygen 1.5.2