Annotation of /branches/mage-next/src/vercomp.c
Parent Directory | Revision Log
Revision 2807 -
(hide annotations)
(download)
Wed Sep 3 11:53:06 2014 UTC (9 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1584 byte(s)
Wed Sep 3 11:53:06 2014 UTC (9 years, 8 months ago) by niro
File MIME type: text/plain
File size: 1584 byte(s)
-moved some common package functions to package.c/package.h
1 | niro | 2585 | /* |
2 | * Copyright (c) 2006-2011 Pacman Development Team <pacman-dev@archlinux.org> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
16 | */ | ||
17 | |||
18 | #include <stdlib.h> | ||
19 | #include <stdio.h> /* printf */ | ||
20 | #include <string.h> | ||
21 | #include <ctype.h> | ||
22 | |||
23 | niro | 2807 | #include "package.h" |
24 | niro | 2585 | |
25 | #define BASENAME "vercmp" | ||
26 | |||
27 | static void usage(void) | ||
28 | { | ||
29 | fprintf(stderr, "usage: %s <ver1> <ver2>\n\n", BASENAME); | ||
30 | fprintf(stderr, "output values:\n"); | ||
31 | fprintf(stderr, " < 0 : if ver1 < ver2\n"); | ||
32 | fprintf(stderr, " 0 : if ver1 == ver2\n"); | ||
33 | fprintf(stderr, " > 0 : if ver1 > ver2\n"); | ||
34 | } | ||
35 | |||
36 | int main(int argc, char *argv[]) | ||
37 | { | ||
38 | const char *s1 = ""; | ||
39 | const char *s2 = ""; | ||
40 | int ret; | ||
41 | |||
42 | if(argc == 1) { | ||
43 | usage(); | ||
44 | return 2; | ||
45 | } | ||
46 | if(argc > 1 && | ||
47 | (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0 | ||
48 | || strcmp(argv[1], "--usage") == 0)) { | ||
49 | usage(); | ||
50 | return 0; | ||
51 | } | ||
52 | if(argc > 2) { | ||
53 | s2 = argv[2]; | ||
54 | } | ||
55 | if(argc > 1) { | ||
56 | s1 = argv[1]; | ||
57 | } | ||
58 | |||
59 | ret = alpm_pkg_vercmp(s1, s2); | ||
60 | printf("%d\n", ret); | ||
61 | return EXIT_SUCCESS; | ||
62 | } |