00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #define _USERDATA_SOURCE_
00021
00022 #include <stdlib.h>
00023
00024 #include "setup.h"
00025
00026 #include "envrnmnt.h"
00027
00028 #include "userdata.h"
00029
00030
00031
00032
00033
00034 globle void InitializeUserDataData(
00035 void *theEnv)
00036 {
00037 AllocateEnvironmentData(theEnv,USER_DATA_DATA,sizeof(struct userDataData),NULL);
00038 }
00039
00040
00041
00042
00043
00044
00045 globle unsigned char InstallUserDataRecord(
00046 void *theEnv,
00047 struct userDataRecord *theRecord)
00048 {
00049 theRecord->dataID = UserDataData(theEnv)->UserDataRecordCount;
00050 UserDataData(theEnv)->UserDataRecordArray[UserDataData(theEnv)->UserDataRecordCount] = theRecord;
00051 return(UserDataData(theEnv)->UserDataRecordCount++);
00052 }
00053
00054
00055
00056
00057
00058
00059 globle struct userData *FetchUserData(
00060 void *theEnv,
00061 unsigned char userDataID,
00062 struct userData **theList)
00063 {
00064 struct userData *theData;
00065
00066 for (theData = *theList;
00067 theData != NULL;
00068 theData = theData->next)
00069 {
00070 if (theData->dataID == userDataID)
00071 { return(theData); }
00072 }
00073
00074 theData = (struct userData *) (*UserDataData(theEnv)->UserDataRecordArray[userDataID]->createUserData)(theEnv);
00075 theData->dataID = userDataID;
00076 theData->next = *theList;
00077 *theList = theData;
00078
00079 return(theData);
00080 }
00081
00082
00083
00084
00085
00086
00087
00088 globle struct userData *TestUserData(
00089 unsigned char userDataID,
00090 struct userData *theList)
00091 {
00092 struct userData *theData;
00093
00094 for (theData = theList;
00095 theData != NULL;
00096 theData = theData->next)
00097 {
00098 if (theData->dataID == userDataID)
00099 { return(theData); }
00100 }
00101
00102 return(NULL);
00103 }
00104
00105
00106
00107
00108 globle void ClearUserDataList(
00109 void *theEnv,
00110 struct userData *theList)
00111 {
00112 struct userData *nextData;
00113
00114 while (theList != NULL)
00115 {
00116 nextData = theList->next;
00117 (*UserDataData(theEnv)->UserDataRecordArray[theList->dataID]->deleteUserData)(theEnv,theList);
00118 theList = nextData;
00119 }
00120 }
00121
00122
00123
00124
00125
00126 globle struct userData *DeleteUserData(
00127 void *theEnv,
00128 unsigned char userDataID,
00129 struct userData *theList)
00130 {
00131 struct userData *theData, *lastData = NULL;
00132
00133 for (theData = theList;
00134 theData != NULL;
00135 theData = theData->next)
00136 {
00137 if (theData->dataID == userDataID)
00138 {
00139 if (lastData == NULL)
00140 { theList = theData->next; }
00141 else
00142 { lastData->next = theData->next; }
00143
00144 (*UserDataData(theEnv)->UserDataRecordArray[userDataID]->deleteUserData)(theEnv,theData);
00145 return(theList);
00146 }
00147
00148 lastData = theData;
00149 }
00150
00151 return(theList);
00152 }
00153