42 #ifdef HFS_DEBUG_PRINT 43 #define PRINT(x) TRACE(TFILE,x) 49 #define MAX_HFS_TABLES 6 69 static HfsTable *hfsTable = &hfsTables[0];
78 static void ClearMappingTable(
void);
79 static void PushMappingTable(
void);
80 static void PopMappingTable(
void);
81 static void ReleaseMapping(
HfsMapping *mapping);
83 static void RemoveMapping(
HfsMapping **pMapping);
87 static void InsertMapping(
HfsMapping *newMapping);
94 #ifdef HFS_DEBUG_TABLE 95 static void PrintMappingTable(
void);
120 while (hfsTable != hfsTables)
157 TRACE(TFILE,(
"(\"%.*s\",\"%.*s\")",
158 (
int)pathName->
len, (
char *)pathName->
data,
159 (
int)mappingList->
len, (
char *)mappingList->
data));
161 if (pathName->
len > 0)
163 pMapping = FindMapping(pathName);
164 if (pMapping != NULL)
166 if (mappingList->
len == 0)
168 RemoveMapping(pMapping);
172 newMapping = CreateMapping(pathName, mappingList);
173 if (newMapping != NULL)
175 ReplaceMapping(pMapping, newMapping);
181 if (mappingList->
len != 0)
183 newMapping = CreateMapping(pathName, mappingList);
184 if (newMapping != NULL)
186 InsertMapping(newMapping);
199 #ifdef HFS_DEBUG_TABLE 220 if (IsValidReference(reference))
222 currentMapping = hfsTable->
anchor;
223 while (currentMapping != NULL)
225 pathName = currentMapping->
pathName;
226 if (longest < pathName.
len)
228 if (pathName.
data[pathName.
len - 1] ==
'/')
231 if (pathName.
len < reference->
len &&
232 memcmp(pathName.
data, reference->
data, pathName.
len) == 0)
234 longest = pathName.
len;
235 mapping = currentMapping;
241 if (pathName.
len == reference->
len &&
242 memcmp(pathName.
data, reference->
data, pathName.
len) == 0)
244 longest = pathName.
len;
245 mapping = currentMapping;
249 currentMapping = currentMapping->
next;
253 TRACE(TFILE,(
"path=%.*s mapping=%.*s",
272 assert(handle != NULL);
274 ReleaseMapping(handle);
285 assert(iter != NULL);
286 assert(mapping != NULL);
309 assert(iter != NULL);
316 reference.
data = NULL;
317 TRACE(TFILE,(
"END"));
325 while (len < limit && data[len] !=
' ')
330 if (data[len - 1] ==
'/')
335 if (reference.
data != NULL)
337 memcpy(reference.
data, data, len);
339 memcpy(reference.
data + reference.
len,
343 reference.
data[reference.
len] =
'\0';
350 if (reference.
data != NULL)
352 memcpy(reference.
data, data, len);
364 TRACE(TFILE,(
"reference=%.*s",(
int)reference.
len, reference.
data));
401 while (output.
len != 0)
403 if (output.
len >= 6 && memcmp(output.
data,
"DSM://", 6) == 0)
429 static void ClearMappingTable(
void)
434 mapping = hfsTable->
anchor;
435 while (mapping != NULL)
438 ReleaseMapping(mapping);
439 mapping = hfsTable->
anchor;
443 hfsTable->
anchor = &defaultMapping;
445 #ifdef HFS_DEBUG_TABLE 455 static void PushMappingTable(
void)
461 assert(newTable->
anchor == NULL ||
462 newTable->
anchor == &defaultMapping);
474 (*new)->refCount = 1;
484 #ifdef HFS_DEBUG_TABLE 494 static void PopMappingTable(
void)
496 assert(hfsTable - hfsTables > 0);
501 #ifdef HFS_DEBUG_TABLE 514 static void ReleaseMapping(
HfsMapping *mapping)
516 if (mapping != &defaultMapping)
541 pMapping = &hfsTable->
anchor;
544 while (mapping != NULL && !match)
546 match = IsStringEqual(pathName, &mapping->
pathName);
549 pMapping = &mapping->
next;
568 static void RemoveMapping(
HfsMapping **pMapping)
573 oldMapping = *pMapping;
574 if (!IsDefaultMapping(oldMapping))
576 nextMapping = oldMapping->
next;
579 *pMapping = nextMapping;
582 ReleaseMapping(oldMapping);
599 oldMapping = (*pMapping);
600 nextMapping = oldMapping->
next;
603 oldMapping->
next = NULL;
606 mapping->
next = nextMapping;
610 ReleaseMapping(oldMapping);
626 if (IsValidInput(pathName, mappingList))
636 mapping->
next = NULL;
660 static void InsertMapping(
HfsMapping *newMapping)
665 newMapping->
next = NULL;
667 pMapping = &hfsTable->
anchor;
668 while (*pMapping != NULL)
673 newMapping->
next = mapping;
678 pMapping = &(*pMapping)->
next;
681 *pMapping = newMapping;
695 if (string->
len == otherString->
len)
697 if (string->
len == 0 ||
699 memcmp(string->
data, otherString->
data, string->
len) == 0))
723 toCompare =
string->len;
724 if (toCompare > otherString->
len)
726 toCompare = otherString->
len;
729 comp = memcmp(string->
data, otherString->
data, toCompare);
730 if (comp > 0 || (comp == 0 && string->
len > otherString->
len))
772 if ((reference->
len > 2) &&
773 (reference->
data[0] ==
'/') && (reference->
data[1] ==
'/'))
811 if (path.
data[path.
len - 1] !=
'/')
828 while (valid && offset < mappingList->
len)
830 while (offset < mappingList->len && mappingList->
data[offset] !=
' ')
835 length = offset - start;
836 PRINT((
"Checking \"%.*s\"\n", (
int)length, mappingList->
data + start));
838 check.
data = mappingList->
data + start;
846 else if (path.
data[path.
len - 1] ==
'/' && isFile)
850 else if (path.
data[path.
len - 1] !=
'/' && !isFile)
863 #ifdef HFS_DEBUG_TABLE 868 static void PrintMappingTable(
void)
872 mapping = hfsTable->
anchor;
873 while (mapping != NULL)
879 mapping = mapping->
next;
struct HfsMapping HfsMapping
void MHEG5ReleaseHybridFileSystemMapping(void *handle)
Release mapping returned from the hybrid file system. The mapping must be have been returned by a cal...
void MHEG5ClearHybridFileSystem(void)
Clear the hybrid file system and restore the default mapping // -> DSM://.
void MHEG5PopHybridFileSystem(void)
Clear the current hybrid file system and pop a stored hybrid file system from the stack...
unsigned char * STR_DataAlloc(unsigned int size)
MHEG5String MHEG5GetFirstDsmReference(MHEG5String *reference)
Return first reference with DSM:// source. This is a convenience function that converts a hybrid:// r...
void * MHEG5GetHybridFileSystemMapping(MHEG5String *reference)
Return mapping from the hybrid file system given path name. The mapping must be released using MHEG5R...
MHEG5String MHEG5stringCopy(MHEG5String source)
<Function description>="">
void MHEG5stringDestruct(MHEG5String *item)
Destruct a MHEG5String.
This file defines the profile for the MHEG engine.
Implement Functions to support Service Gateways. Functions for standarizing several GroupIDs like +DS...
void MHEG5PushHybridFileSystem(void)
Push a copy of the current hybrid file system into the stack.
MHEG5String MHEG5convertGIDGetOrigin(MHEG5String *inRef, E_FS_ORIGIN *pOrigin)
Convert a group ID from a relative reference to an absolute reference. See UK1.05 section 8...
void MHEG5InitialiseHybridFileSystem(void)
Initialise the hybrid file system. The hybrid file system is a set of mappings from a "path" string (...
void MHEG5InitMappingIter(MHEG5MappingIter_t *iter, void *mapping)
Initialise hybrid filesystem mapping iterator.
System Wide Global Technical Data Type Definitions.
MHEG5String MHEG5GetNextReference(MHEG5String *ref, MHEG5MappingIter_t *iter)
Return next reference from mapping iterator.
void MHEG5SetHybridFileSystem(MHEG5String *pathName, MHEG5String *mappingList)
Set mapping list in the hybrid file system. This function sets, clears or modifies the list of mappin...
Functions relating to Hybrid file system.