~ubuntu-branches/ubuntu/lucid/graphviz/lucid-security

« back to all changes in this revision

Viewing changes to tools/sfio/Sfio_dc/sfdcslow.c

  • Committer: Bazaar Package Importer
  • Author(s): Stephen M Moraco
  • Date: 2002-02-05 18:52:12 UTC
  • Revision ID: james.westby@ubuntu.com-20020205185212-8i04c70te00rc40y
Tags: upstream-1.7.16
ImportĀ upstreamĀ versionĀ 1.7.16

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "sfdchdr.h"
 
2
 
 
3
/*      Make a stream op return immediately on interrupts.
 
4
**      This is useful on slow streams (hence the name).
 
5
**
 
6
**      Written by Glenn Fowler (03/18/1998).
 
7
*/
 
8
 
 
9
#if __STD_C
 
10
static int slowexcept(Sfio_t* f, int type, Void_t* v, Sfdisc_t* disc)
 
11
#else
 
12
static int slowexcept(f, type, v, disc)
 
13
Sfio_t*         f;
 
14
int             type;
 
15
Void_t*         v;
 
16
Sfdisc_t*       disc;
 
17
#endif
 
18
{
 
19
        NOTUSED(f);
 
20
        NOTUSED(v);
 
21
        NOTUSED(disc);
 
22
 
 
23
        switch (type)
 
24
        {
 
25
        case SF_FINAL:
 
26
        case SF_DPOP:
 
27
                free(disc);
 
28
                break;
 
29
        case SF_READ:
 
30
        case SF_WRITE:
 
31
                if (errno == EINTR)
 
32
                        return(-1);
 
33
                break;
 
34
        }
 
35
 
 
36
        return(0);
 
37
}
 
38
 
 
39
#if __STD_C
 
40
int sfdcslow(Sfio_t* f)
 
41
#else
 
42
int sfdcslow(f)
 
43
Sfio_t* f;
 
44
#endif
 
45
{
 
46
        Sfdisc_t*       disc;
 
47
 
 
48
        if(!(disc = (Sfdisc_t*)malloc(sizeof(Sfdisc_t))) )
 
49
                return(-1);
 
50
 
 
51
        disc->readf = NIL(Sfread_f);
 
52
        disc->writef = NIL(Sfwrite_f);
 
53
        disc->seekf = NIL(Sfseek_f);
 
54
        disc->exceptf = slowexcept;
 
55
 
 
56
        if(sfdisc(f,disc) != disc)
 
57
        {       free(disc);
 
58
                return(-1);
 
59
        }
 
60
 
 
61
        return(0);
 
62
}