/[gentoo-projects]/portage-utils/qatom.c
Gentoo

Contents of /portage-utils/qatom.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.8 - (show annotations) (download) (as text)
Mon Feb 21 01:33:47 2011 UTC (3 years, 9 months ago) by vapier
Branch: MAIN
Changes since 1.7: +3 -3 lines
File MIME type: text/x-csrc
constify more strings

1 /*
2 * Copyright 2005-2008 Gentoo Foundation
3 * Distributed under the terms of the GNU General Public License v2
4 * $Header: /var/cvsroot/gentoo-projects/portage-utils/qatom.c,v 1.7 2008/01/15 08:06:09 vapier Exp $
5 *
6 * Copyright 2005-2008 Ned Ludd - <solar@gentoo.org>
7 * Copyright 2005-2008 Mike Frysinger - <vapier@gentoo.org>
8 */
9
10 #ifdef APPLET_qatom
11
12 #define QATOM_FLAGS "c" COMMON_FLAGS
13 static struct option const qatom_long_opts[] = {
14 {"compare", no_argument, NULL, 'c'},
15 COMMON_LONG_OPTS
16 };
17 static const char * const qatom_opts_help[] = {
18 "Compare two atoms",
19 COMMON_OPTS_HELP
20 };
21
22 static const char qatom_rcsid[] = "$Id: qatom.c,v 1.7 2008/01/15 08:06:09 vapier Exp $";
23 #define qatom_usage(ret) usage(ret, QATOM_FLAGS, qatom_long_opts, qatom_opts_help, lookup_applet_idx("qatom"))
24
25 int qatom_main(int argc, char **argv)
26 {
27 enum qatom_atom { _EXPLODE=0, _COMPARE } action = _EXPLODE;
28 depend_atom *atom;
29 int i;
30
31 DBG("argc=%d argv[0]=%s argv[1]=%s",
32 argc, argv[0], argc > 1 ? argv[1] : "NULL?");
33
34 while ((i = GETOPT_LONG(QATOM, qatom, "")) != -1) {
35 switch (i) {
36 case 'c': action = _COMPARE; break;
37 COMMON_GETOPTS_CASES(qatom)
38 }
39 }
40
41 if (argc == optind)
42 qatom_usage(EXIT_FAILURE);
43
44 for (i = optind; i < argc; ++i) {
45 switch (action) {
46 case _COMPARE:
47 if (i+1 == argc)
48 errf("Wrong number of arguments");
49 printf("%s %s %s\n", argv[i], booga[atom_compare_str(argv[i], argv[i+1])], argv[i+1]);
50 ++i;
51 break;
52 case _EXPLODE:
53 atom = atom_explode(argv[i]);
54 if (!atom) {
55 warnf("failed exploding atom %s", argv[i]);
56 continue;
57 }
58 printf("%s %s %s", atom->CATEGORY, atom->PN, atom->PV);
59 if (verbose || atom->PR_int)
60 printf(" r%i", atom->PR_int);
61 if (atom->SLOT)
62 printf(" :%s", atom->SLOT);
63 if (verbose > 1)
64 printf(" %c", (atom->letter ? : '-'));
65 putchar('\n');
66 atom_implode(atom);
67 }
68 }
69
70 return EXIT_SUCCESS;
71 }
72
73 #else
74 DEFINE_APPLET_STUB(qatom)
75 #endif

  ViewVC Help
Powered by ViewVC 1.1.20