📄 fs80entitydata.c
字号:
#ifdef FSS_FTR#define ACCESS_RIGHTS_INTERNAL_FS#define FS80ENTITYDATA_C#include "Fs.h"#undef FILE_NUMBER#define FILE_NUMBER 80 /* Local prototypes */void Fs80_03EDInsertEntity ( t_RtkID vp_RtkId, u16 vp_InsertIndex );/* Local variables */t_EntityDataBaseStruct s_EntityDataBaseStruct;/**//*P(***************************************************************************//* Procedure name : Fs80_01EDInitEntityData *//* Object : Initialize entity data *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_FsConfiguration * pp_Config: Pointer on FS configuration *//* *//* Output parameters : *//* ------------------- *//* none *//* *//* Used variables : *//* ------------------- *//* *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Initialization of entity data management *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 1void Fs80_01EDInitEntityData( t_FsConfiguration * pp_Config ){ t_fsEntityStruct ** pl_EntityStruct; u16 i; /* Initialize entity data structure */ s_EntityDataBaseStruct.v_NbrMaxEntitys = pp_Config->v_NbrMaxEntitys; s_EntityDataBaseStruct.v_NbrEntitys = 0; s_EntityDataBaseStruct.v_BeginningIndex = 0; /* Reserve table indexed by FS ID */ s_EntityDataBaseStruct.p_EntityIndexedByFsId = pl_EntityStruct = (t_fsEntityStruct **) MC_FS_GET_MEMORY ( sizeof(t_fsEntityStruct *) * pp_Config->v_NbrMaxEntitys ); /* Initialize all the table to free */ for ( i = 0; i < pp_Config->v_NbrMaxEntitys; i++ ) { pl_EntityStruct[i] = NIL; } /* Reserve the RTK-E to FS ID translation table */ s_EntityDataBaseStruct.p_TabTranslRtkFs = (t_IDTranslStruct *) MC_FS_GET_MEMORY( sizeof( t_IDTranslStruct ) * pp_Config->v_NbrMaxEntitys );}/*P(***************************************************************************//* Procedure name : Fs80_02EDGetFsId *//* Object : Translates the RTK-ID in FS ID *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_RtkID vp_RtkID : The RTK-E entity's ID *//* *//* *//* Output parameters : *//* ------------------- *//* returned value: u16 Fs Id *//* *//* Used variables : *//* ------------------- *//* RTK-E to FS translation table *//* *//* Used procedures : *//* ------------------- *//* Fs80_03EDInsertEntity ( RtkId ) *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Translates the RTK-E ID in FS ID by searching dychotomeous in translation *//* table. If RTK-E table do not exist it is inserted in table *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 2u16 Fs80_02EDGetFsId ( t_RtkID vp_RtkId ){ u16 vl_NbrEntitys, vl_RestIndex; s16 vl_Index; t_IDTranslStruct * p_IDPtr = s_EntityDataBaseStruct.p_TabTranslRtkFs; vl_NbrEntitys = s_EntityDataBaseStruct.v_NbrEntitys; if ( vl_NbrEntitys != 0 ) { vl_Index = vl_RestIndex = s_EntityDataBaseStruct.v_BeginningIndex; /* If Search dichotomeus in translation table */ do { vl_RestIndex = vl_RestIndex >> 1; if ( vl_Index < vl_NbrEntitys ) { if ( p_IDPtr[vl_Index].v_RtkID == vp_RtkId ) return ( p_IDPtr[vl_Index].v_FsID ); else if ( p_IDPtr[vl_Index].v_RtkID < vp_RtkId ) vl_Index = vl_Index + vl_RestIndex ; else vl_Index = vl_Index - vl_RestIndex ; } else { vl_Index = vl_Index - vl_RestIndex ; } } while ( vl_RestIndex != 0 ); /* Index 0 would 'nt scanned from dychotomeous search, if position is 1 verify it */ if ( vl_Index == 1) { /* If value in index 0 OK return FsID */ if ( p_IDPtr[0].v_RtkID == vp_RtkId ) return ( p_IDPtr[0].v_FsID ); /* Else if value in position 0 greather than searched value point on position 0 */ if ( p_IDPtr[0].v_RtkID > vp_RtkId ) vl_Index = 0; } /* Like insertion is made before pointed element if this element is less than this inserted we have to point just after it */ if ( vl_Index < vl_NbrEntitys ) { if ( p_IDPtr[vl_Index].v_RtkID < vp_RtkId ) vl_Index++; } } /* Table is empty -> insert index is 0 */ else vl_Index = 0; /* RTK-E ID not found, insert the new entity in translation table */ Fs80_03EDInsertEntity ( vp_RtkId , vl_Index); return ( p_IDPtr[vl_Index].v_FsID );}/*P(***************************************************************************//* Procedure name : Fs80_03EDInsertEntity *//* Object : Inserts a new entity in entity's data *//*----------------------------------------------------------------------------*//* Input parameters : *//* ------------------- *//* t_RtkID vp_RtkID : The RTK-E entity's ID *//* u16 vp_InsertIndex : The index in translation table where the new *//* entity is inserted *//* *//* Output parameters : *//* ------------------- *//* returned value: *//* *//* Used variables : *//* ------------------- *//* RTK-E to FS translation table *//* *//* Used procedures : *//* ------------------- *//* *//* *//*----------------------------------------------------------------------------*//*----------------------------------------------------------------------------*//* DESCRIPTION *//* *//* Inserts the new entity in the entity's data , for this insert it in *//* Id translation table. in entity's pointer table and gets creates the *//* entity's structure. *//* *//*----------------------------------------------------------------------------*//***************************************************************************)P*//* #*/#undef PROCEDURE_NUMBER #define PROCEDURE_NUMBER 3void Fs80_03EDInsertEntity ( t_RtkID vp_RtkId, u16 vp_InsertIndex ){ u16 vl_FsEntityId; bool vl_Found= 0; t_fsEntityStruct ** pl_TabPtrEntity = s_EntityDataBaseStruct.p_EntityIndexedByFsId; /* Search an available place in entity's pointer table ( index will be the FS ID ) */ for ( vl_FsEntityId = 0; vl_FsEntityId < s_EntityDataBaseStruct.v_NbrMaxEntitys ; vl_FsEntityId++ ) { if ( * pl_TabPtrEntity == 0 ) { vl_Found = 1; break; } pl_TabPtrEntity++; } /* If table full set a defense */ if ( !vl_Found ) FS_EXCPTHANDLER( FS_BLOCKED, FS_EXCPT_TOO_MUTCH_ENTITYS ); /* Construct a new entity's structure and initialize it */ { register t_fsEntityStruct * pl_Entity = (t_fsEntityStruct *) MC_FS_GET_MEMORY( sizeof(t_fsEntityStruct)); pl_Entity -> p_Path = ( ascii * ) MC_FS_GET_MEMORY(2); *pl_Entity -> p_Path = '/'; *(pl_Entity->p_Path +1) = '\0'; pl_Entity -> v_PathLenght = 1; pl_Entity -> p_CurrentVolume = NIL; pl_Entity -> v_DirLevelNExist = FALSE; pl_Entity -> v_DirLevelN_1Exist = FALSE; pl_Entity -> p_FileList = NIL; pl_Entity -> p_DirList = NIL; pl_Entity -> v_RtkID = vp_RtkId; pl_Entity -> v_CurrPathValid = TRUE; /* Update pointer in entity pointer table */ *pl_TabPtrEntity = pl_Entity; } /* Insert the new entity in RTK ID to FS ID translation table */ { t_IDTranslStruct * p_Id = s_EntityDataBaseStruct.p_TabTranslRtkFs; t_IDTranslStruct * p_Srce; t_IDTranslStruct * p_Dst; u16 vl_Size = s_EntityDataBaseStruct.v_NbrEntitys - vp_InsertIndex; /* If insertion not made at end of table shift table content */ if ( vl_Size != 0 ) { p_Dst = &p_Id[vp_InsertIndex + vl_Size];
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -