Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / usr.sbin / pkg_install / lib / version.c
1 /*
2  * FreeBSD install - a package for the installation and maintenance
3  * of non-core utilities.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  * 1. Redistributions of source code must retain the above copyright
9  *    notice, this list of conditions and the following disclaimer.
10  * 2. Redistributions in binary form must reproduce the above copyright
11  *    notice, this list of conditions and the following disclaimer in the
12  *    documentation and/or other materials provided with the distribution.
13  *
14  * Maxim Sobolev
15  * 31 July 2001
16  *
17  * $FreeBSD: src/usr.sbin/pkg_install/lib/version.c,v 1.1.2.3 2002/08/20 06:35:08 obrien Exp $
18  * $DragonFly: src/usr.sbin/pkg_install/lib/Attic/version.c,v 1.2 2003/06/17 04:29:59 dillon Exp $
19  */
20
21 #include "lib.h"
22 #include <err.h>
23
24 /*
25  * Routines to assist with PLIST_FMT_VER numbers in the packing
26  * lists.
27  *
28  * Following is the PLIST_FMT_VER history:
29  * 1.0 - Initial revision;
30  * 1.1 - When recording/checking checksum of symlink use hash of readlink()
31  *       value instead of the hash of an object this links points to.
32  *
33  */
34 int
35 verscmp(Package *pkg, int major, int minor)
36 {
37     int rval = 0;
38
39     if ((pkg->fmtver_maj < major) || (pkg->fmtver_maj == major &&
40         pkg->fmtver_mnr < minor))
41         rval = -1;
42     else if ((pkg->fmtver_maj > major) || (pkg->fmtver_maj == major &&
43              pkg->fmtver_mnr > minor))
44         rval = 1;
45
46     return rval;
47 }