Deleted Added
full compact
main.c (173412) main.c (179433)
1/*
2 * FreeBSD install - a package for the installation and maintainance
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

--- 5 unchanged lines hidden (view full) ---

14 * Jeremy D. Lea.
15 * 11 May 2002
16 *
17 * This is the version module. Based on pkg_version.pl by Bruce A. Mah.
18 *
19 */
20
21#include <sys/cdefs.h>
1/*
2 * FreeBSD install - a package for the installation and maintainance
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

--- 5 unchanged lines hidden (view full) ---

14 * Jeremy D. Lea.
15 * 11 May 2002
16 *
17 * This is the version module. Based on pkg_version.pl by Bruce A. Mah.
18 *
19 */
20
21#include <sys/cdefs.h>
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/version/main.c 173412 2007-11-07 10:53:41Z kevlo $");
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/version/main.c 179433 2008-05-30 14:26:09Z flz $");
23
23
24
25#include <getopt.h>
26#include <err.h>
27
24#include "lib.h"
25#include "version.h"
28#include "lib.h"
29#include "version.h"
26#include <err.h>
27
30
28static char Options[] = "dIhl:L:qs:XtTO:ov";
29
30char *LimitChars = NULL;
31char *PreventChars = NULL;
32char *MatchName = NULL;
33char *LookUpOrigin = NULL;
34Boolean RegexExtended = FALSE;
35Boolean UseINDEXOnly = FALSE;
36Boolean ShowOrigin = FALSE;
37
38static void usage(void);
39
31char *LimitChars = NULL;
32char *PreventChars = NULL;
33char *MatchName = NULL;
34char *LookUpOrigin = NULL;
35Boolean RegexExtended = FALSE;
36Boolean UseINDEXOnly = FALSE;
37Boolean ShowOrigin = FALSE;
38
39static void usage(void);
40
41static char opts[] = "dIhl:L:qs:XtTO:ov";
42static struct option longopts[] = {
43 { "extended", no_argument, NULL, 'X' },
44 { "help", no_argument, NULL, 'h' },
45 { "match", required_argument, NULL, 's' },
46 { "no-status", required_argument, NULL, 'L' },
47 { "origin", required_argument, NULL, 'O' },
48 { "quiet", no_argument, NULL, 'q' },
49 { "show-origin",no_argument, NULL, 'o' },
50 { "status", required_argument, NULL, 'l' },
51 { "index-only", no_argument, NULL, 'I' },
52 { "verbose", no_argument, NULL, 'v' },
53 { NULL, 0, NULL, 0 }
54};
55
40int
41main(int argc, char **argv)
42{
43 int ch, cmp = 0;
44
45 if (argc == 4 && !strcmp(argv[1], "-t")) {
46 cmp = version_cmp(argv[2], argv[3]);
47 printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));
48 exit(0);
49 }
50 else if (argc == 4 && !strcmp(argv[1], "-T")) {
51 cmp = version_match(argv[3], argv[2]);
52 exit(cmp == 1 ? 0 : 1);
53 }
56int
57main(int argc, char **argv)
58{
59 int ch, cmp = 0;
60
61 if (argc == 4 && !strcmp(argv[1], "-t")) {
62 cmp = version_cmp(argv[2], argv[3]);
63 printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));
64 exit(0);
65 }
66 else if (argc == 4 && !strcmp(argv[1], "-T")) {
67 cmp = version_match(argv[3], argv[2]);
68 exit(cmp == 1 ? 0 : 1);
69 }
54 else while ((ch = getopt(argc, argv, Options)) != -1) {
70 else while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) {
55 switch(ch) {
56 case 'v':
57 Verbose++;
58 break;
59
60 case 'I':
61 UseINDEXOnly = TRUE;
62 break;

--- 30 unchanged lines hidden (view full) ---

93 errx(2, "Invalid -T usage.");
94 break;
95
96 case 'X':
97 RegexExtended = TRUE;
98 break;
99
100 case 'h':
71 switch(ch) {
72 case 'v':
73 Verbose++;
74 break;
75
76 case 'I':
77 UseINDEXOnly = TRUE;
78 break;

--- 30 unchanged lines hidden (view full) ---

109 errx(2, "Invalid -T usage.");
110 break;
111
112 case 'X':
113 RegexExtended = TRUE;
114 break;
115
116 case 'h':
101 case '?':
102 default:
103 usage();
104 break;
105 }
106 }
107
108 argc -= optind;
109 argv += optind;

--- 13 unchanged lines hidden ---
117 default:
118 usage();
119 break;
120 }
121 }
122
123 argc -= optind;
124 argv += optind;

--- 13 unchanged lines hidden ---