+static index_t IndexSegment(Segments *segments,Segment *segment);
+
+
+/*++++++++++++++++++++++++++++++++++++++
+ Find the Segment information for a particular segment.
+
+ Segment *LookupSegment Returns a pointer to the cached segment information.
+
+ Segments *segments The segments structure to use.
+
+ index_t index The index of the segment.
+
+ int position The position in the cache to store the value.
+ ++++++++++++++++++++++++++++++++++++++*/
+
+static inline Segment *LookupSegment(Segments *segments,index_t index,int position)
+{
+ SeekFile(segments->fd,sizeof(SegmentsFile)+(off_t)index*sizeof(Segment));
+
+ ReadFile(segments->fd,&segments->cached[position-1],sizeof(Segment));
+
+ segments->incache[position-1]=index;
+
+ return(&segments->cached[position-1]);
+}
+
+
+/*++++++++++++++++++++++++++++++++++++++
+ Find the segment index for a particular segment pointer.
+
+ index_t IndexSegment Returns the index of the segment in the list.
+
+ Segments *segments The segments structure to use.
+
+ Segment *segment The segment whose index is to be found.
+ ++++++++++++++++++++++++++++++++++++++*/
+
+static inline index_t IndexSegment(Segments *segments,Segment *segment)
+{
+ int i;
+
+ for(i=0;i<sizeof(segments->cached)/sizeof(segments->cached[0]);i++)
+ if(&segments->cached[i]==segment)
+ return(segments->incache[i]);
+
+ return(NO_SEGMENT);
+}
+
+#endif