perform.c (112572) | perform.c (131275) |
---|---|
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 * Jordan K. Hubbard 15 * 23 Aug 1993 16 * 17 * This is the main body of the info module. 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 * Jordan K. Hubbard 15 * 23 Aug 1993 16 * 17 * This is the main body of the info module. 18 * 19 */ 20 21#include <sys/cdefs.h> |
22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/info/perform.c 112572 2003-03-25 00:51:41Z mdodd $"); | 22__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/info/perform.c 131275 2004-06-29 18:54:47Z eik $"); |
23 24#include "lib.h" 25#include "info.h" 26#include <err.h> 27#include <signal.h> 28 29static int pkg_do(char *); 30static int find_pkg(struct which_head *); 31static int cmp_path(const char *, const char *, const char *); 32static char *abspath(const char *); 33static int find_pkgs_by_origin(const char *); | 23 24#include "lib.h" 25#include "info.h" 26#include <err.h> 27#include <signal.h> 28 29static int pkg_do(char *); 30static int find_pkg(struct which_head *); 31static int cmp_path(const char *, const char *, const char *); 32static char *abspath(const char *); 33static int find_pkgs_by_origin(const char *); |
34static int matched_packages(char **pkgs); |
|
34 35int 36pkg_perform(char **pkgs) 37{ 38 char **matched; 39 int err_cnt = 0; 40 int i, errcode; 41 42 signal(SIGINT, cleanup); 43 44 /* Overriding action? */ | 35 36int 37pkg_perform(char **pkgs) 38{ 39 char **matched; 40 int err_cnt = 0; 41 int i, errcode; 42 43 signal(SIGINT, cleanup); 44 45 /* Overriding action? */ |
45 if (CheckPkg) { | 46 if (Flags & SHOW_PKGNAME) { 47 return matched_packages(pkgs); 48 } else if (CheckPkg) { |
46 return isinstalledpkg(CheckPkg) == TRUE ? 0 : 1; 47 /* Not reached */ 48 } else if (!TAILQ_EMPTY(whead)) { 49 return find_pkg(whead); 50 } else if (LookUpOrigin != NULL) { 51 return find_pkgs_by_origin(LookUpOrigin); 52 } 53 --- 8 unchanged lines hidden (view full) --- 62 else switch (MatchType) { 63 case MATCH_GLOB: 64 break; 65 case MATCH_ALL: 66 warnx("no packages installed"); 67 return 0; 68 /* Not reached */ 69 case MATCH_REGEX: | 49 return isinstalledpkg(CheckPkg) == TRUE ? 0 : 1; 50 /* Not reached */ 51 } else if (!TAILQ_EMPTY(whead)) { 52 return find_pkg(whead); 53 } else if (LookUpOrigin != NULL) { 54 return find_pkgs_by_origin(LookUpOrigin); 55 } 56 --- 8 unchanged lines hidden (view full) --- 65 else switch (MatchType) { 66 case MATCH_GLOB: 67 break; 68 case MATCH_ALL: 69 warnx("no packages installed"); 70 return 0; 71 /* Not reached */ 72 case MATCH_REGEX: |
73 case MATCH_EREGEX: |
|
70 warnx("no packages match pattern(s)"); 71 return 1; 72 /* Not reached */ 73 default: 74 break; 75 } 76 } 77 --- 368 unchanged lines hidden (view full) --- 446 if (matched == NULL) 447 return errcode; 448 449 for (i = 0; matched[i] != NULL; i++) 450 puts(matched[i]); 451 452 return 0; 453} | 74 warnx("no packages match pattern(s)"); 75 return 1; 76 /* Not reached */ 77 default: 78 break; 79 } 80 } 81 --- 368 unchanged lines hidden (view full) --- 450 if (matched == NULL) 451 return errcode; 452 453 for (i = 0; matched[i] != NULL; i++) 454 puts(matched[i]); 455 456 return 0; 457} |
458 459/* 460 * List only the matching package names. 461 * Mainly intended for scripts. 462 */ 463static int 464matched_packages(char **pkgs) 465{ 466 char **matched; 467 int i, errcode; 468 469 matched = matchinstalled(MatchType == MATCH_GLOB ? MATCH_NGLOB : MatchType, pkgs, &errcode); 470 471 if (errcode != 0 || matched == NULL) 472 return 1; 473 474 for (i = 0; matched[i]; i++) 475 if (!Quiet) 476 printf("%s\n", matched[i]); 477 else if (QUIET) 478 printf("%s%s\n", InfoPrefix, matched[i]); 479 480 return 0; 481} |
|