main.c (173514) | main.c (179433) |
---|---|
1/*- 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <beat@chruetertee.ch> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Beat G�tzi 7 * ---------------------------------------------------------------------------- 8 */ 9 10#include <sys/cdefs.h> | 1/*- 2 * ---------------------------------------------------------------------------- 3 * "THE BEER-WARE LICENSE" (Revision 42): 4 * <beat@chruetertee.ch> wrote this file. As long as you retain this notice you 5 * can do whatever you want with this stuff. If we meet some day, and you think 6 * this stuff is worth it, you can buy me a beer in return. Beat G�tzi 7 * ---------------------------------------------------------------------------- 8 */ 9 10#include <sys/cdefs.h> |
11__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/updating/main.c 173514 2007-11-10 10:21:29Z krion $"); | 11__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/updating/main.c 179433 2008-05-30 14:26:09Z flz $"); |
12 13#include <errno.h> 14#include <limits.h> 15#include <sysexits.h> | 12 13#include <errno.h> 14#include <limits.h> 15#include <sysexits.h> |
16#include <getopt.h> |
|
16 17#include "lib.h" 18#include "pathnames.h" 19 20typedef struct installedport { 21 struct installedport *next; /* List of installed ports. */ 22 char name[LINE_MAX]; /* Name of the installed port. */ 23} INSTALLEDPORT; 24 25int usage(void); 26 | 17 18#include "lib.h" 19#include "pathnames.h" 20 21typedef struct installedport { 22 struct installedport *next; /* List of installed ports. */ 23 char name[LINE_MAX]; /* Name of the installed port. */ 24} INSTALLEDPORT; 25 26int usage(void); 27 |
28static char opts[] = "d:f:h"; 29static struct option longopts[] = { 30 { "date", required_argument, NULL, 'd' }, 31 { "file", required_argument, NULL, 'f' }, 32 { "help", no_argument, NULL, 'h' }, 33 { NULL, 0, NULL, 0 }, 34}; 35 |
|
27/* 28 * Parse /usr/port/UPDATING for corresponding entries. If no argument is 29 * passed to pkg_updating all entries for all installed ports are displayed. 30 * If a list of portnames is passed to pkg_updating only entries for the 31 * given portnames are displayed. Use the -d option to define that only newer 32 * entries as this date are shown. 33 */ 34int --- 34 unchanged lines hidden (view full) --- 69 70 /* Needed nodes for linked list with installed ports. */ 71 INSTALLEDPORT *head = (INSTALLEDPORT *) NULL; 72 INSTALLEDPORT *curr = (INSTALLEDPORT *) NULL; 73 74 DIR *dir; 75 FILE *fd; 76 | 36/* 37 * Parse /usr/port/UPDATING for corresponding entries. If no argument is 38 * passed to pkg_updating all entries for all installed ports are displayed. 39 * If a list of portnames is passed to pkg_updating only entries for the 40 * given portnames are displayed. Use the -d option to define that only newer 41 * entries as this date are shown. 42 */ 43int --- 34 unchanged lines hidden (view full) --- 78 79 /* Needed nodes for linked list with installed ports. */ 80 INSTALLEDPORT *head = (INSTALLEDPORT *) NULL; 81 INSTALLEDPORT *curr = (INSTALLEDPORT *) NULL; 82 83 DIR *dir; 84 FILE *fd; 85 |
77 while ((ch = getopt(argc, argv, "f:d:")) != -1) { | 86 while ((ch = getopt_long(argc, argv, opts, longopts, NULL)) != -1) { |
78 switch (ch) { 79 case 'd': 80 dflag = 1; 81 date = optarg; 82 break; 83 case 'f': 84 updatingfile = optarg; 85 break; | 87 switch (ch) { 88 case 'd': 89 dflag = 1; 90 date = optarg; 91 break; 92 case 'f': 93 updatingfile = optarg; 94 break; |
86 case '?': | 95 case 'h': |
87 default: 88 usage(); 89 } 90 } 91 argc -= optind; 92 argv += optind; 93 94 /* Check if passed date has a correct format. */ --- 147 unchanged lines hidden (view full) --- 242 243 exit(EX_OK); 244} 245 246int 247usage(void) 248{ 249 fprintf(stderr, | 96 default: 97 usage(); 98 } 99 } 100 argc -= optind; 101 argv += optind; 102 103 /* Check if passed date has a correct format. */ --- 147 unchanged lines hidden (view full) --- 251 252 exit(EX_OK); 253} 254 255int 256usage(void) 257{ 258 fprintf(stderr, |
250 "usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n"); | 259 "usage: pkg_updating [-h] [-d YYYYMMDD] [-f file] [portname ...]\n"); |
251 exit(EX_USAGE); 252} 253 254void 255cleanup(int sig) 256{ 257 if (sig) 258 exit(1); 259} | 260 exit(EX_USAGE); 261} 262 263void 264cleanup(int sig) 265{ 266 if (sig) 267 exit(1); 268} |