First SVN commit
[fapman] / apt-src / debversion.h
1 /*
2 Apt is copyright 1997, 1998, 1999 Jason Gunthorpe and others.
3 Apt is currently developed by APT Development Team <deity@lists.debian.org>.
4
5 License: GPLv2+
6
7         This program is free software; you can redistribute it and/or modify
8         it under the terms of the GNU General Public License as published by
9         the Free Software Foundation; either version 2 of the License, or
10         (at your option) any later version.
11
12         This program is distributed in the hope that it will be useful,
13         but WITHOUT ANY WARRANTY; without even the implied warranty of
14         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15         GNU General Public License for more details.
16
17         You should have received a copy of the GNU General Public License
18         along with this program; if not, write to the Free Software
19         Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
20
21 See /usr/share/common-licenses/GPL-2, or
22 <http://www.gnu.org/copyleft/gpl.txt> for the terms of the latest version
23 of the GNU General Public License.
24 */
25
26 // -*- mode: cpp; mode: fold -*-
27 // Description                                                          /*{{{*/
28 // $Id: debversion.h,v 1.3 2001/05/03 05:25:04 jgg Exp $
29 /* ######################################################################
30
31    Debian Version - Versioning system for Debian
32
33    This implements the standard Debian versioning system.
34    
35    ##################################################################### */
36                                                                         /*}}}*/
37 #ifndef PKGLIB_DEBVERSION_H
38 #define PKGLIB_DEBVERSION_H
39
40
41
42 #include "version.h"
43     
44 class debVersioningSystem : public pkgVersioningSystem
45 {     
46    public:
47    
48    static int CmpFragment(const char *A, const char *AEnd, const char *B,
49                           const char *BEnd);
50    
51    // Compare versions..
52    virtual int DoCmpVersion(const char *A,const char *Aend,
53                           const char *B,const char *Bend);
54    virtual bool CheckDep(const char *PkgVer,int Op,const char *DepVer);
55    virtual int DoCmpReleaseVer(const char *A,const char *Aend,
56                              const char *B,const char *Bend)
57    {
58       return DoCmpVersion(A,Aend,B,Bend);
59    }   
60    virtual string UpstreamVersion(const char *A);
61
62    debVersioningSystem();
63 };
64
65 extern debVersioningSystem debVS;
66
67 #ifdef APT_COMPATIBILITY
68 #if APT_COMPATIBILITY != 986
69 #warning "Using APT_COMPATIBILITY"
70 #endif
71
72 inline int pkgVersionCompare(const char *A, const char *B)
73 {
74    return debVS.CmpVersion(A,B);
75 }
76 inline int pkgVersionCompare(const char *A, const char *AEnd, 
77                              const char *B, const char *BEnd)
78 {
79    return debVS.DoCmpVersion(A,AEnd,B,BEnd);
80 }
81 inline int pkgVersionCompare(string A,string B)
82 {
83    return debVS.CmpVersion(A,B);
84 }
85 inline bool pkgCheckDep(const char *DepVer,const char *PkgVer,int Op)
86 {
87    return debVS.CheckDep(PkgVer,Op,DepVer);
88 }
89 inline string pkgBaseVersion(const char *Ver)
90 {
91    return debVS.UpstreamVersion(Ver);
92 }
93 #endif
94
95 #endif