3
/* Function to clear a locked stream.
4
** This is useful for programs that longjmp from the mid of an sfio function.
5
** There is no guarantee on data integrity in such a case.
7
** Written by Kiem-Phong Vo
10
int sfclrlock(reg Sfio_t* f)
19
if(f && (f->mode&SF_AVAIL))
24
/* clear error bits */
25
f->flags &= ~(SF_ERROR|SF_EOF);
27
/* clear peek locks */
29
{ f->here -= f->endb-f->next;
35
/* throw away all lock bits except for stacking state SF_PUSH */
36
f->mode &= (SF_RDWR|SF_INIT|SF_POOL|SF_PUSH|SF_SYNCED|SF_STDIO);
38
rv = (f->mode&SF_PUSH) ? 0 : (f->flags&SF_FLAGS);