diff options
author | Arch Librarian <arch@canonical.com> | 2004-09-20 16:52:13 +0000 |
---|---|---|
committer | Arch Librarian <arch@canonical.com> | 2004-09-20 16:52:13 +0000 |
commit | b0b4efb96c3fad90bf978d61b230501bcdadff3d (patch) | |
tree | 63c6013b85da3fe3835f1ef37466c91279fa9c47 /apt-pkg/tagfile.cc | |
parent | 30456e14d97be16516a5a84ce9bf9acba143da87 (diff) |
Release support
Author: jgg
Date: 1998-12-14 02:23:46 GMT
Release support
Diffstat (limited to 'apt-pkg/tagfile.cc')
-rw-r--r-- | apt-pkg/tagfile.cc | 55 |
1 files changed, 48 insertions, 7 deletions
diff --git a/apt-pkg/tagfile.cc b/apt-pkg/tagfile.cc index 7f2bf6b1d..eb0840366 100644 --- a/apt-pkg/tagfile.cc +++ b/apt-pkg/tagfile.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: tagfile.cc,v 1.18 1998/12/08 05:24:41 jgg Exp $ +// $Id: tagfile.cc,v 1.19 1998/12/14 02:23:47 jgg Exp $ /* ###################################################################### Fast scanner for RFC-822 type header information @@ -17,6 +17,7 @@ #include <apt-pkg/tagfile.h> #include <apt-pkg/error.h> +#include <strutl.h> #include <string> #include <stdio.h> @@ -225,14 +226,54 @@ string pkgTagSection::FindS(const char *Tag) // TagSection::FindI - Find an integer /*{{{*/ // --------------------------------------------------------------------- /* */ -unsigned int pkgTagSection::FindI(const char *Tag) +signed int pkgTagSection::FindI(const char *Tag,signed long Default) { const char *Start; - const char *End; - if (Find(Tag,Start,End) == false) - return 0; + const char *Stop; + if (Find(Tag,Start,Stop) == false) + return Default; + + // Copy it into a temp buffer so we can use strtol + char S[300]; + if ((unsigned)(Stop - Start) >= sizeof(S)) + return Default; + strncpy(S,Start,Stop-Start); + S[Stop - Start] = 0; + + char *End; + signed long Result = strtol(S,&End,10); + if (S == End) + return Default; + return Result; +} + /*}}}*/ +// TagSection::FindFlag - Locate a yes/no type flag /*{{{*/ +// --------------------------------------------------------------------- +/* The bits marked in Flag are masked on/off in Flags */ +bool pkgTagSection::FindFlag(const char *Tag,unsigned long &Flags, + unsigned long Flag) +{ + const char *Start; + const char *Stop; + if (Find(Tag,Start,Stop) == false) + return true; - return atoi(string(Start,End).c_str()); + switch (StringToBool(string(Start,Stop))) + { + case 0: + Flags &= ~Flag; + return true; + + case 1: + Flags |= Flag; + return true; + + default: + _error->Warning("Unknown flag value"); + return true; + } + return true; } /*}}}*/ - + + |