/***********************************************************************1* *2* This software is part of the ast package *3* Copyright (c) 1985-2011 AT&T Intellectual Property *4* and is licensed under the *5* Eclipse Public License, Version 1.0 *6* by AT&T Intellectual Property *7* *8* A copy of the License is available at *9* http://www.eclipse.org/org/documents/epl-v10.html *10* (with md5 checksum b35adb5213ca9657e911e9befb180842) *11* *12* Information and Software Systems Research *13* AT&T Research *14* Florham Park NJ *15* *16* Glenn Fowler <[email protected]> *17* David Korn <[email protected]> *18* Phong Vo <[email protected]> *19* *20***********************************************************************/21#include "sfdchdr.h"2223/* Make a stream op return immediately on interrupts.24** This is useful on slow streams (hence the name).25**26** Written by Glenn Fowler (03/18/1998).27*/2829#if __STD_C30static int slowexcept(Sfio_t* f, int type, Void_t* v, Sfdisc_t* disc)31#else32static int slowexcept(f, type, v, disc)33Sfio_t* f;34int type;35Void_t* v;36Sfdisc_t* disc;37#endif38{39NOTUSED(f);40NOTUSED(v);41NOTUSED(disc);4243switch (type)44{45case SF_FINAL:46case SF_DPOP:47free(disc);48break;49case SF_READ:50case SF_WRITE:51if (errno == EINTR)52return(-1);53break;54}5556return(0);57}5859#if __STD_C60int sfdcslow(Sfio_t* f)61#else62int sfdcslow(f)63Sfio_t* f;64#endif65{66Sfdisc_t* disc;6768if(!(disc = (Sfdisc_t*)malloc(sizeof(Sfdisc_t))) )69return(-1);7071disc->readf = NIL(Sfread_f);72disc->writef = NIL(Sfwrite_f);73disc->seekf = NIL(Sfseek_f);74disc->exceptf = slowexcept;7576if(sfdisc(f,disc) != disc)77{ free(disc);78return(-1);79}80sfset(f,SF_IOINTR,1);8182return(0);83}848586