Consider an ordered array, If *pos != 0, you could return data using *pos as a simple byte offset or you could use *pos as an element offset into your array (it's up to you). My usage right now involves returning arrayed kernel data expressed as XML, I allow for the user to skip into the array (by elements) if they choose to on some tables and others I allow them only to start at the beginning. In these cases, if *pos != 0, I return NULL (for the start*() methods). If the next*() method is offset past the end of my array, I return NULL, otherwise I increment *pos (as most generic examples will show). *pos is really just a tool for the user. If you want your data to behave as a "normal" block file, you have the onus to provide the mechanism for indexing into your data with *pos and maintain the position of *pos. Expect the unexpected. If I recall correctly, perusing the source code for seq_file (it's a real mess!) shows that *pos is not forced to zero. -Bruce
|