1 /*******************************************************/ 2 /* "C" Language Integrated Production System */ 3 /* */ 4 /* CLIPS Version 6.30 08/19/14 */ 5 /* */ 6 /* MULTIFIELD HEADER FILE */ 7 /*******************************************************/ 8 9 /*************************************************************/ 10 /* Purpose: Routines for creating and manipulating */ 11 /* multifield values. */ 12 /* */ 13 /* Principal Programmer(s): */ 14 /* Gary D. Riley */ 15 /* */ 16 /* Contributing Programmer(s): */ 17 /* */ 18 /* Revision History: */ 19 /* */ 20 /* 6.24: Renamed BOOLEAN macro type to intBool. */ 21 /* */ 22 /* Corrected code to remove compiler warnings. */ 23 /* */ 24 /* Moved ImplodeMultifield from multifun.c. */ 25 /* */ 26 /* 6.30: Changed integer type/precision. */ 27 /* */ 28 /* Changed garbage collection algorithm. */ 29 /* */ 30 /* Used DataObjectToString instead of */ 31 /* ValueToString in implode$ to handle */ 32 /* print representation of external addresses. */ 33 /* */ 34 /* Added const qualifiers to remove C++ */ 35 /* deprecation warnings. */ 36 /* */ 37 /* Converted API macros to function calls. */ 38 /* */ 39 /* Fixed issue with StoreInMultifield when */ 40 /* asserting void values in implied deftemplate */ 41 /* facts. */ 42 /* */ 43 /*************************************************************/ 44 45 #ifndef _H_multifld 46 47 #define _H_multifld 48 49 struct field; 50 struct multifield; 51 52 #ifndef _H_evaluatn 53 #include "evaluatn.h" 54 #endif 55 56 struct field 57 { 58 unsigned short type; 59 void *value; 60 }; 61 62 struct multifield 63 { 64 unsigned busyCount; 65 long multifieldLength; 66 struct multifield *next; 67 struct field theFields[1]; 68 }; 69 70 typedef struct multifield SEGMENT; 71 typedef struct multifield * SEGMENT_PTR; 72 typedef struct multifield * MULTIFIELD_PTR; 73 typedef struct field FIELD; 74 typedef struct field * FIELD_PTR; 75 76 #define GetMFLength(target) (((struct multifield *) (target))->multifieldLength) 77 #define GetMFPtr(target,index) (&(((struct field *) ((struct multifield *) (target))->theFields)[index-1])) 78 #define SetMFType(target,index,value) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].type = (unsigned short) (value)) 79 #define SetMFValue(target,index,val) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].value = (void *) (val)) 80 #define GetMFType(target,index) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].type) 81 #define GetMFValue(target,index) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].value) 82 83 #define EnvGetMFLength(theEnv,target) (((struct multifield *) (target))->multifieldLength) 84 #define EnvGetMFPtr(theEnv,target,index) (&(((struct field *) ((struct multifield *) (target))->theFields)[index-1])) 85 #define EnvSetMFType(theEnv,target,index,value) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].type = (unsigned short) (value)) 86 #define EnvSetMFValue(theEnv,target,index,val) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].value = (void *) (val)) 87 #define EnvGetMFType(theEnv,target,index) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].type) 88 #define EnvGetMFValue(theEnv,target,index) (((struct field *) ((struct multifield *) (target))->theFields)[index-1].value) 89 90 #ifdef LOCALE 91 #undef LOCALE 92 #endif 93 #ifdef _MULTIFLD_SOURCE_ 94 #define LOCALE 95 #else 96 #define LOCALE extern 97 #endif 98 99 LOCALE void *CreateMultifield2(void *,long); 100 LOCALE void ReturnMultifield(void *,struct multifield *); 101 LOCALE void MultifieldInstall(void *,struct multifield *); 102 LOCALE void MultifieldDeinstall(void *,struct multifield *); 103 LOCALE struct multifield *StringToMultifield(void *,const char *); 104 LOCALE void *EnvCreateMultifield(void *,long); 105 LOCALE void AddToMultifieldList(void *,struct multifield *); 106 LOCALE void FlushMultifields(void *); 107 LOCALE void DuplicateMultifield(void *,struct dataObject *,struct dataObject *); 108 LOCALE void PrintMultifield(void *,const char *,SEGMENT_PTR,long,long,int); 109 LOCALE intBool MultifieldDOsEqual(DATA_OBJECT_PTR,DATA_OBJECT_PTR); 110 LOCALE void StoreInMultifield(void *,DATA_OBJECT *,EXPRESSION *,int); 111 LOCALE void *CopyMultifield(void *,struct multifield *); 112 LOCALE intBool MultifieldsEqual(struct multifield *,struct multifield *); 113 LOCALE void *DOToMultifield(void *,DATA_OBJECT *); 114 LOCALE unsigned long HashMultifield(struct multifield *,unsigned long); 115 LOCALE struct multifield *GetMultifieldList(void *); 116 LOCALE void *ImplodeMultifield(void *,DATA_OBJECT *); 117 118 #if ALLOW_ENVIRONMENT_GLOBALS 119 120 LOCALE void *CreateMultifield(long); 121 122 #endif /* ALLOW_ENVIRONMENT_GLOBALS */ 123 124 #endif /* _H_multifld */ 125 126 127 128 129