11
** PSIO_TOCCLEAN(): Delete all TOC entries after the given key.
12
** If a blank key is given, the entire TOC will be wiped.
17
int psio_tocclean(unsigned int unit, char *key)
19
psio_tocentry *this_entry, *last_entry, *prev_entry;
21
/* Check the key length first */
22
if((strlen(key)+1) > PSIO_KEYLEN) psio_error(unit,PSIO_ERROR_KEYLEN);
24
this_entry = psio_tocscan(unit, key);
25
if(this_entry == NULL) {
26
if(!strcmp(key,"")) this_entry = psio_unit[unit].toc;
28
fprintf(stderr, "PSIO_ERROR: Can't find TOC Entry %s\n", key);
29
psio_error(unit,PSIO_ERROR_NOTOCENT);
32
else this_entry = this_entry->next;
34
/* Get the end of the TOC and work backwards */
35
last_entry = psio_toclast(unit);
37
while((last_entry != this_entry) && (last_entry != NULL)) {
38
/* Now free all the remaining members */
39
prev_entry = last_entry->last;
41
last_entry = prev_entry;