main.c (173295) | main.c (173514) |
---|---|
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 173295 2007-11-02 22:46:30Z krion $"); | 11__FBSDID("$FreeBSD: head/usr.sbin/pkg_install/updating/main.c 173514 2007-11-10 10:21:29Z krion $"); |
12 | 12 |
13#include <sys/stat.h> 14#include <sys/param.h> /* For MAXPATHLEN */ 15 16#include <dirent.h> | |
17#include <errno.h> 18#include <limits.h> | 13#include <errno.h> 14#include <limits.h> |
19#include <stdio.h> 20#include <stdlib.h> 21#include <string.h> | |
22#include <sysexits.h> | 15#include <sysexits.h> |
23#include <unistd.h> | |
24 | 16 |
17#include "lib.h" |
|
25#include "pathnames.h" 26 27typedef struct installedport { 28 struct installedport *next; /* List of installed ports. */ 29 char name[LINE_MAX]; /* Name of the installed port. */ 30} INSTALLEDPORT; 31 32int usage(void); --- 43 unchanged lines hidden (view full) --- 76 77 /* Needed nodes for linked list with installed ports. */ 78 INSTALLEDPORT *head = (INSTALLEDPORT *) NULL; 79 INSTALLEDPORT *curr = (INSTALLEDPORT *) NULL; 80 81 DIR *dir; 82 FILE *fd; 83 | 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); --- 43 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 |
84 while ((ch = getopt(argc, argv, "f:p:d:")) != -1) { | 77 while ((ch = getopt(argc, argv, "f:d:")) != -1) { |
85 switch (ch) { 86 case 'd': 87 dflag = 1; 88 date = optarg; 89 break; 90 case 'f': 91 updatingfile = optarg; 92 break; --- 48 unchanged lines hidden (view full) --- 141 sizeof(tmp_file) - n); 142 if(stat(tmp_file, &attribute) == -1) { 143 fprintf(stderr, "can't open %s: %s\n", 144 tmp_file, strerror(errno)); 145 return EXIT_FAILURE; 146 } 147 if(attribute.st_mode & S_IFREG) 148 continue; | 78 switch (ch) { 79 case 'd': 80 dflag = 1; 81 date = optarg; 82 break; 83 case 'f': 84 updatingfile = optarg; 85 break; --- 48 unchanged lines hidden (view full) --- 134 sizeof(tmp_file) - n); 135 if(stat(tmp_file, &attribute) == -1) { 136 fprintf(stderr, "can't open %s: %s\n", 137 tmp_file, strerror(errno)); 138 return EXIT_FAILURE; 139 } 140 if(attribute.st_mode & S_IFREG) 141 continue; |
149 (void)strlcat(tmp_file + n, "/+CONTENTS", | 142 (void)strlcat(tmp_file + n, "/", |
150 sizeof(tmp_file) - n); | 143 sizeof(tmp_file) - n); |
144 (void)strlcat(tmp_file + n, CONTENTS_FNAME, 145 sizeof(tmp_file) - n); |
|
151 152 /* Open +CONTENT file */ 153 fd = fopen(tmp_file, "r"); 154 if(fd == NULL) { 155 fprintf(stderr, "warning: can't open %s: %s\n", 156 tmp_file, strerror(errno)); 157 continue; 158 } --- 91 unchanged lines hidden (view full) --- 250 251int 252usage(void) 253{ 254 fprintf(stderr, 255 "usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n"); 256 exit(EX_USAGE); 257} | 146 147 /* Open +CONTENT file */ 148 fd = fopen(tmp_file, "r"); 149 if(fd == NULL) { 150 fprintf(stderr, "warning: can't open %s: %s\n", 151 tmp_file, strerror(errno)); 152 continue; 153 } --- 91 unchanged lines hidden (view full) --- 245 246int 247usage(void) 248{ 249 fprintf(stderr, 250 "usage: pkg_updating [-d YYYYMMDD] [-f file] [portname ...]\n"); 251 exit(EX_USAGE); 252} |
253 254void 255cleanup(int sig) 256{ 257 if (sig) 258 exit(1); 259} |
|