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.
19 * $FreeBSD: src/usr.sbin/pkg_install/version/main.c,v 1.4 2005/01/11 11:23:59 ru Exp $
20 * $DragonFly: src/usr.sbin/pkg_install/version/Attic/main.c,v 1.2 2005/03/08 19:11:30 joerg Exp $
27 static char Options[] = "dhl:L:qs:XtTv";
29 char *LimitChars = NULL;
30 char *PreventChars = NULL;
31 char *MatchName = NULL;
32 Boolean RegexExtended = FALSE;
34 static void usage(void);
37 main(int argc, char **argv)
41 if (argc == 4 && !strcmp(argv[1], "-t")) {
42 cmp = version_cmp(argv[2], argv[3]);
43 printf(cmp > 0 ? ">\n" : (cmp < 0 ? "<\n" : "=\n"));
46 else if (argc == 4 && !strcmp(argv[1], "-T")) {
47 cmp = version_match(argv[3], argv[2]);
48 exit(cmp == 1 ? 0 : 1);
50 else while ((ch = getopt(argc, argv, Options)) != -1) {
61 PreventChars = optarg;
73 errx(2, "Invalid -t usage.");
77 errx(2, "Invalid -T usage.");
95 return pkg_perform(argv);
101 fprintf(stderr, "%s\n%s\n%s\n",
102 "usage: pkg_version [-hqv] [-l limchar] [-L limchar] [[-X] -s string] index",
103 " pkg_version -t v1 v2",
104 " pkg_version -T name pattern");