2 * FreeBSD install - a package for the installation and maintainance
3 * of non-core utilities.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
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.
17 * This is the version module. Based on pkg_version.pl by Bruce A. Mah.
21 #include <sys/cdefs.h>
22 __FBSDID("$FreeBSD$");
28 static char Options[] = "dIhl:L:qs:XtTO:ov";
30 char *LimitChars = NULL;
31 char *PreventChars = NULL;
32 char *MatchName = NULL;
33 char *LookUpOrigin = NULL;
34 Boolean RegexExtended = FALSE;
35 Boolean UseINDEXOnly = FALSE;
36 Boolean ShowOrigin = FALSE;
38 static void usage __P((void));
41 main(int argc, char **argv)
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"));
50 else if (argc == 4 && !strcmp(argv[1], "-T")) {
51 cmp = version_match(argv[3], argv[2]);
52 exit(cmp == 1 ? 0 : 1);
54 else while ((ch = getopt(argc, argv, Options)) != -1) {
69 PreventChars = optarg;
81 LookUpOrigin = optarg;
89 errx(2, "Invalid -t usage.");
93 errx(2, "Invalid -T usage.");
111 return pkg_perform(argv);
117 fprintf(stderr, "%s\n%s\n%s\n",
118 "usage: pkg_version [-hIoqv] [-l limchar] [-L limchar] [[-X] -s string] [-O origin] [index]",
119 " pkg_version -t v1 v2",
120 " pkg_version -T name pattern");