int load_datafile_text(GameDriver drv, ref string buffer, int bufsize, tDatafileIndex[] idx, string tag) { throw new Exception(); }
int index_datafile(ref tDatafileIndex[] _index) { tDatafileIndex idx; int ix = 0; int count = 0; uint token = TOKEN_SYMBOL; /* rewind file */ if (ParseSeek(0, SEEK_SET)) return 0; /* allocate index */ _index = new tDatafileIndex[MAX_DATAFILE_ENTRIES]; idx = _index[ix]; /* loop through datafile */ while ((count < (MAX_DATAFILE_ENTRIES - 1)) && TOKEN_INVALID != token) { uint tell = 0; string s = ""; token = GetNextToken(ref s, ref tell); if (TOKEN_SYMBOL != token) continue; /* DATAFILE_TAG_KEY identifies the driver */ if (ci_strncmp(DATAFILE_TAG_KEY, s, DATAFILE_TAG_KEY.Length) == 0) { token = GetNextToken(ref s, ref tell); if (TOKEN_EQUALS == token) { bool done = false; token = GetNextToken(ref s, ref tell); while (!done && TOKEN_SYMBOL == token) { /* search for matching driver name */ foreach (string gn in drivers) { if (s.ToLower().CompareTo(gn.ToLower()) == 0) { /* found correct driver -- fill in index entry */ idx.driver = GetDriver(gn); idx.offset = (int)tell; idx = _index[++ix]; count++; done = true; break; } } if (!done) { token = GetNextToken(ref s, ref tell); if (TOKEN_COMMA == token) token = GetNextToken(ref s, ref tell); else done = true; /* end of key field */ } } } } } /* mark end of index */ idx.offset = 0; idx.driver = null; return count; }