83 lines
3.1 KiB
C
83 lines
3.1 KiB
C
/*
|
|
* CDE - Common Desktop Environment
|
|
*
|
|
* Copyright (c) 1993-2012, The Open Group. All rights reserved.
|
|
*
|
|
* These libraries and programs are free software; you can
|
|
* redistribute them and/or modify them under the terms of the GNU
|
|
* Lesser General Public License as published by the Free Software
|
|
* Foundation; either version 2 of the License, or (at your option)
|
|
* any later version.
|
|
*
|
|
* These libraries and programs are distributed in the hope that
|
|
* they will be useful, but WITHOUT ANY WARRANTY; without even the
|
|
* implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
* PURPOSE. See the GNU Lesser General Public License for more
|
|
* details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with these libraries and programs; if not, write
|
|
* to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
|
|
* Floor, Boston, MA 02110-1301 USA
|
|
*/
|
|
/* $XConsortium: sfclrlock.c /main/3 1995/11/01 18:27:23 rswiston $ */
|
|
/***************************************************************
|
|
* *
|
|
* AT&T - PROPRIETARY *
|
|
* *
|
|
* THIS IS PROPRIETARY SOURCE CODE LICENSED BY *
|
|
* AT&T CORP. *
|
|
* *
|
|
* Copyright (c) 1995 AT&T Corp. *
|
|
* All Rights Reserved *
|
|
* *
|
|
* This software is licensed by AT&T Corp. *
|
|
* under the terms and conditions of the license in *
|
|
* http://www.research.att.com/orgs/ssr/book/reuse *
|
|
* *
|
|
* This software was created by the *
|
|
* Software Engineering Research Department *
|
|
* AT&T Bell Laboratories *
|
|
* *
|
|
* For further information contact *
|
|
* gsf@research.att.com *
|
|
* *
|
|
***************************************************************/
|
|
#include "sfhdr.h"
|
|
|
|
/* Function to clear a locked stream.
|
|
** This is useful for programs that longjmp from the mid of an sfio function.
|
|
** There is no guarantee on data integrity in such a case.
|
|
**
|
|
** Written by Kiem-Phong Vo (07/20/90).
|
|
*/
|
|
#if __STD_C
|
|
int sfclrlock(reg Sfio_t* f)
|
|
#else
|
|
sfclrlock(f)
|
|
reg Sfio_t *f;
|
|
#endif
|
|
{
|
|
/* already closed */
|
|
if(f->mode&SF_AVAIL)
|
|
return 0;
|
|
|
|
/* clear these bits */
|
|
f->flags &= ~(SF_ERROR|SF_EOF);
|
|
|
|
if(!(f->mode&(SF_LOCK|SF_PEEK)) )
|
|
return (f->flags&SFIO_FLAGS);
|
|
|
|
/* clear peek locks */
|
|
f->mode &= ~SF_PEEK;
|
|
if(f->mode&SF_PKRD)
|
|
{ f->here -= f->endb-f->next;
|
|
f->endb = f->next;
|
|
f->mode &= ~SF_PKRD;
|
|
}
|
|
|
|
f->mode &= (SF_RDWR|SF_INIT|SF_POOL|SF_PUSH|SF_SYNCED|SF_STDIO);
|
|
|
|
return _sfmode(f,0,0) < 0 ? 0 : (f->flags&SFIO_FLAGS);
|
|
}
|