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

« back to all changes in this revision

Viewing changes to tools/sfio/sfgetu.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        "sfhdr.h"
 
2
 
 
3
/*      Read an unsigned long value coded in a portable format.
 
4
**
 
5
**      Written by Kiem-Phong Vo
 
6
*/
 
7
 
 
8
#if __STD_C
 
9
Sfulong_t sfgetu(reg Sfio_t* f)
 
10
#else
 
11
Sfulong_t sfgetu(f)
 
12
reg Sfio_t*     f;
 
13
#endif
 
14
{
 
15
        Sfulong_t       v;
 
16
        reg uchar       *s, *ends, c;
 
17
        reg int         p;
 
18
 
 
19
        SFMTXSTART(f, (Sfulong_t)(-1));
 
20
 
 
21
        if(f->mode != SF_READ && _sfmode(f,SF_READ,0) < 0)
 
22
                SFMTXRETURN(f, (Sfulong_t)(-1));
 
23
 
 
24
        SFLOCK(f,0);
 
25
 
 
26
        for(v = 0;;)
 
27
        {       if(SFRPEEK(f,s,p) <= 0)
 
28
                {       f->flags |= SF_ERROR;
 
29
                        v = (Sfulong_t)(-1);
 
30
                        goto done;
 
31
                }
 
32
                for(ends = s+p; s < ends;)
 
33
                {       c = *s++;
 
34
                        v = (v << SF_UBITS) | SFUVALUE(c);
 
35
                        if(!(c&SF_MORE))
 
36
                        {       f->next = s;
 
37
                                goto done;
 
38
                        }
 
39
                }
 
40
                f->next = s;
 
41
        }
 
42
done:
 
43
        SFOPEN(f,0);
 
44
        SFMTXRETURN(f, v);
 
45
}