#define SF_DPOLL 7 /* see if stream is ready for I/O */
#define SF_DBUFFER 8 /* buffer not empty during push or pop */
#define SF_SYNC 9 /* announcing start/end synchronization */
-#define SF_PURGE 10 /* a sfpurge() call was issued */
#define SF_FINAL 11 /* closing is done except stream free */
#define SF_READY 12 /* a polled stream is ready */
#define SF_LOCKED 13 /* stream is in a locked state */
extern Sfio_t *sfopen(Sfio_t *, const char *, const char *);
extern Sfio_t *sfstack(Sfio_t *, Sfio_t *);
extern Sfio_t *sfswap(Sfio_t *, Sfio_t *);
- extern int sfpurge(Sfio_t *);
extern int sfsync(Sfio_t *);
extern void *sfsetbuf(Sfio_t *, void *, size_t);
extern Sfdisc_t *sfdisc(Sfio_t *, Sfdisc_t *);
+++ /dev/null
-/* $Id$ $Revision$ */
-/* vim:set shiftwidth=4 ts=8: */
-
-/*************************************************************************
- * Copyright (c) 2011 AT&T Intellectual Property
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors: See CVS logs. Details at http://www.graphviz.org/
- *************************************************************************/
-
-#include <sfio/sfhdr.h>
-
-/* Delete all pending data in the buffer
-**
-** Written by Kiem-Phong Vo.
-*/
-
-int sfpurge(Sfio_t * f)
-{
- int mode;
-
- SFMTXSTART(f, -1);
-
- if ((mode = f->mode & SF_RDWR) != (int) f->mode
- && _sfmode(f, mode, 0) < 0)
- SFMTXRETURN(f, -1);
-
- if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_PURGE, (void *) ((int) 1),
- f->disc);
-
- if (f->disc == _Sfudisc)
- (void) sfclose((*_Sfstack) (f, NIL(Sfio_t *)));
-
- /* cannot purge read string streams */
- if ((f->flags & SF_STRING) && (f->mode & SF_READ))
- goto done;
-
- SFLOCK(f, 0);
-
- switch (f->mode & ~SF_LOCK) {
- default:
- SFOPEN(f, 0);
- SFMTXRETURN(f, -1);
- case SF_WRITE:
- f->next = f->data;
- if (!f->proc || !(f->flags & SF_READ) || !(f->mode & SF_WRITE))
- break;
-
- /* 2-way pipe, must clear read buffer */
- (void) _sfmode(f, SF_READ, 1);
- /* fall through */
- case SF_READ:
- if (f->extent >= 0 && f->endb > f->next) {
- f->here -= f->endb - f->next;
- SFSK(f, f->here, SEEK_SET, f->disc);
- }
- f->endb = f->next = f->data;
- break;
- }
-
- SFOPEN(f, 0);
-
- done:
- if ((f->flags & SF_IOCHECK) && f->disc && f->disc->exceptf)
- (void) (*f->disc->exceptf) (f, SF_PURGE, (void *) ((int) 0),
- f->disc);
-
- SFMTXRETURN(f, 0);
-}