Deleted Added
full compact
ftree.c (76017) ftree.c (76351)
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
41#endif
42static const char rcsid[] =
1/*-
2 * Copyright (c) 1992 Keith Muller.
3 * Copyright (c) 1992, 1993
4 * The Regents of the University of California. All rights reserved.
5 *
6 * This code is derived from software contributed to Berkeley by
7 * Keith Muller of the University of California, San Diego.
8 *

--- 26 unchanged lines hidden (view full) ---

35 * SUCH DAMAGE.
36 */
37
38#ifndef lint
39#if 0
40static char sccsid[] = "@(#)ftree.c 8.2 (Berkeley) 4/18/94";
41#endif
42static const char rcsid[] =
43 "$FreeBSD: head/bin/pax/ftree.c 76017 2001-04-26 08:37:00Z kris $";
43 "$FreeBSD: head/bin/pax/ftree.c 76351 2001-05-08 06:19:06Z kris $";
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/time.h>
48#include <sys/stat.h>
49#include <unistd.h>
50#include <string.h>
51#include <stdio.h>

--- 95 unchanged lines hidden (view full) ---

147 * add the arg to the linked list of files to process. Each will be
148 * processed by fts one at a time
149 * Return:
150 * 0 if added to the linked list, -1 if failed
151 */
152
153#ifdef __STDC__
154int
44#endif /* not lint */
45
46#include <sys/types.h>
47#include <sys/time.h>
48#include <sys/stat.h>
49#include <unistd.h>
50#include <string.h>
51#include <stdio.h>

--- 95 unchanged lines hidden (view full) ---

147 * add the arg to the linked list of files to process. Each will be
148 * processed by fts one at a time
149 * Return:
150 * 0 if added to the linked list, -1 if failed
151 */
152
153#ifdef __STDC__
154int
155ftree_add(register char *str)
155ftree_add(register char *str, int chflg)
156#else
157int
156#else
157int
158ftree_add(str)
158ftree_add(str, chflg)
159 register char *str;
159 register char *str;
160 int chflg;
160#endif
161{
162 register FTREE *ft;
163 register int len;
164
165 /*
166 * simple check for bad args
167 */

--- 11 unchanged lines hidden (view full) ---

179 paxwarn(0, "Unable to allocate memory for filename");
180 return(-1);
181 }
182
183 if (((len = strlen(str) - 1) > 0) && (str[len] == '/'))
184 str[len] = '\0';
185 ft->fname = str;
186 ft->refcnt = 0;
161#endif
162{
163 register FTREE *ft;
164 register int len;
165
166 /*
167 * simple check for bad args
168 */

--- 11 unchanged lines hidden (view full) ---

180 paxwarn(0, "Unable to allocate memory for filename");
181 return(-1);
182 }
183
184 if (((len = strlen(str) - 1) > 0) && (str[len] == '/'))
185 str[len] = '\0';
186 ft->fname = str;
187 ft->refcnt = 0;
188 ft->chflg = chflg;
187 ft->fow = NULL;
188 if (fthead == NULL) {
189 fttail = fthead = ft;
190 return(0);
191 }
192 fttail->fow = ft;
193 fttail = ft;
194 return(0);

--- 61 unchanged lines hidden (view full) ---

256 if (tflag)
257 atdir_end();
258
259 /*
260 * walk down list and check reference count. Print out those members
261 * that never had a match
262 */
263 for (ft = fthead; ft != NULL; ft = ft->fow) {
189 ft->fow = NULL;
190 if (fthead == NULL) {
191 fttail = fthead = ft;
192 return(0);
193 }
194 fttail->fow = ft;
195 fttail = ft;
196 return(0);

--- 61 unchanged lines hidden (view full) ---

258 if (tflag)
259 atdir_end();
260
261 /*
262 * walk down list and check reference count. Print out those members
263 * that never had a match
264 */
265 for (ft = fthead; ft != NULL; ft = ft->fow) {
264 if (ft->refcnt > 0)
266 if ((ft->refcnt > 0) || ft->chflg)
265 continue;
266 if (wban == 0) {
267 paxwarn(1,"WARNING! These file names were not selected:");
268 ++wban;
269 }
270 (void)fprintf(stderr, "%s\n", ft->fname);
271 }
272}

--- 43 unchanged lines hidden (view full) ---

316 } else {
317 /*
318 * the user supplied the file args as arguments to pax
319 */
320 if (ftcur == NULL)
321 ftcur = fthead;
322 else if ((ftcur = ftcur->fow) == NULL)
323 return(-1);
267 continue;
268 if (wban == 0) {
269 paxwarn(1,"WARNING! These file names were not selected:");
270 ++wban;
271 }
272 (void)fprintf(stderr, "%s\n", ft->fname);
273 }
274}

--- 43 unchanged lines hidden (view full) ---

318 } else {
319 /*
320 * the user supplied the file args as arguments to pax
321 */
322 if (ftcur == NULL)
323 ftcur = fthead;
324 else if ((ftcur = ftcur->fow) == NULL)
325 return(-1);
324 farray[0] = ftcur->fname;
326 if (ftcur->chflg) {
327 /* First fchdir() back... */
328 if (fchdir(cwdfd) < 0) {
329 syswarn(1, errno,
330 "Can't fchdir to starting directory");
331 return(-1);
332 }
333 if (chdir(ftcur->fname) < 0) {
334 syswarn(1, errno, "Can't chdir to %s",
335 ftcur->fname);
336 return(-1);
337 }
338 continue;
339 } else
340 farray[0] = ftcur->fname;
325 }
326
327 /*
328 * watch it, fts wants the file arg stored in a array of char
329 * ptrs, with the last one a null. we use a two element array
330 * and set farray[0] to point at the buffer with the file name
331 * in it. We cannot pass all the file args to fts at one shot
332 * as we need to keep a handle on which file arg generates what

--- 200 unchanged lines hidden (view full) ---

533 break;
534 }
535 break;
536 }
537
538 /*
539 * copy file name, set file name length
540 */
341 }
342
343 /*
344 * watch it, fts wants the file arg stored in a array of char
345 * ptrs, with the last one a null. we use a two element array
346 * and set farray[0] to point at the buffer with the file name
347 * in it. We cannot pass all the file args to fts at one shot
348 * as we need to keep a handle on which file arg generates what

--- 200 unchanged lines hidden (view full) ---

549 break;
550 }
551 break;
552 }
553
554 /*
555 * copy file name, set file name length
556 */
541 arcn->nlen = l_strncpy(arcn->name, ftent->fts_path, PAXPATHLEN+1);
557 arcn->nlen = l_strncpy(arcn->name, ftent->fts_path, sizeof(arcn->name) - 1);
542 arcn->name[arcn->nlen] = '\0';
543 arcn->org_name = ftent->fts_path;
544 return(0);
545}
558 arcn->name[arcn->nlen] = '\0';
559 arcn->org_name = ftent->fts_path;
560 return(0);
561}