+++ /dev/null
-#define _POSIX_C_SOURCE 2
-#include <stdlib.h>
-#include <stdio.h>
-#include <unistd.h>
-
-#include "zpm.h"
-
-int main(int ac, char **av) {
- int rel;
- char name[256];
- char ver[256];
- int i;
- int found;
- int pname = 0;
- int pver = 0;
- int prel = 0;
- int printed = 0;
- int opt;
- int pdefault = 1;
- int eval = 0;
-
- while ((opt = getopt(ac, av, "nvrE")) != -1) {
- switch (opt) {
- case 'n': pdefault = 0; pname = 1; break;
- case 'v': pdefault = 0; pver = 1; break;
- case 'r': pdefault = 0; prel = 1; break;
- case 'E': eval = 1; break;
- default:
- fprintf(stderr, "zpm parse [-nvrE] ...\n");
- exit(EXIT_FAILURE);
- break;
- }
- }
-
- pname = pname || pdefault;
- pver = pver || pdefault;
- prel = prel || pdefault;
-
- for (i=optind; i<ac; i++) {
- printed = 0;
- found = zpm_parse_package(av[i], name, ver, &rel);
- /* single quotes aren't allowed, so a simple single quote
- * is sufficient for eval */
- if (found >= 1 && pname) {
- if (eval) {
- printf("name='%s'\n", name);
- } else {
- printf("%s", name);
- printed++;
- }
- }
- if (found >= 2 && pver) {
- if (eval) {
- printf("version='%s'\n", ver);
- } else {
- printf("%s%s", printed ? " " : "", ver);
- printed++;
- }
- }
- if (found >= 3 && prel) {
- if (eval) {
- printf("release='%d'\n", rel);
- } else {
- printf("%s%d", printed ? " " : "", rel);
- printed++;
- }
- }
- if (printed) {
- putchar('\n');
- }
- if (!found) {
- exit(EXIT_FAILURE);
- }
- }
- return 0;
-}