home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 2 / FFMCD02.bin / useful / dist / gnu / fileutils / fileutils-3.9-amiga / src / cp-aux.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-18  |  3.4 KB  |  100 lines

  1. /* cp-aux.c  -- file copying (auxiliary routines)
  2.    Copyright (C) 1989, 1990, 1991 Free Software Foundation.
  3.  
  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 2, or (at your option)
  7.    any later version.
  8.  
  9.    This program is distributed in the hope that it will be useful,
  10.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  11.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  12.    GNU General Public License for more details.
  13.  
  14.    You should have received a copy of the GNU General Public License
  15.    along with this program; if not, write to the Free Software
  16.    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17.  
  18.    Written by Torbjorn Granlund, Sweden (tege@sics.se). */
  19.  
  20. #ifdef HAVE_CONFIG_H
  21. #if defined (CONFIG_BROKETS)
  22. /* We use <config.h> instead of "config.h" so that a compilation
  23.    using -I. -I$srcdir will use ./config.h rather than $srcdir/config.h
  24.    (which it would do because it found this file in $srcdir).  */
  25. #include <config.h>
  26. #else
  27. #include "config.h"
  28. #endif
  29. #endif
  30.  
  31. #include <stdio.h>
  32.  
  33. #include "cp.h"
  34.  
  35. extern char *program_name;
  36.  
  37. void
  38. usage (status, reason)
  39.      int status;
  40.      char *reason;
  41. {
  42.   if (reason != NULL)
  43.     fprintf (status == 0 ? stdout : stderr, "%s: %s\n",
  44.          program_name, reason);
  45.  
  46.   if (status != 0)
  47.     fprintf (stderr, "Try `%s --help' for more information.\n",
  48.          program_name);
  49.   else
  50.     {
  51.       printf ("\
  52. Usage: %s [OPTION]... SOURCE DEST\n\
  53.   or:  %s [OPTION]... SOURCE... DIRECTORY\n\
  54. ",
  55.           program_name, program_name);
  56.       printf ("\
  57. \n\
  58.   -a, --archive                same as -dpr\n\
  59.   -b, --backup                 make backup before removal\n\
  60.   -d, --no-dereference         preserve links\n\
  61.   -f, --force                  remove existing destinations, never prompt\n\
  62.   -i, --interactive            prompt before overwrite\n\
  63.   -l, --link                   link files instead of copying\n\
  64.   -p, --preserve               preserve file attributes if possible\n\
  65.   -r                           copy recursively, non-directories as files\n\
  66.   -s, --symbolic-link          make symbolic links instead of copying\n\
  67.   -u, --update                 copy only older or brand new files\n\
  68.   -v, --verbose                explain what is being done\n\
  69.   -x, --one-file-system        stay on this file system\n\
  70.   -P, --parents                append source path to DIRECTORY\n\
  71.   -R, --recursive              copy directories recursively\n\
  72.   -S, --suffix SUFFIX          override the usual backup suffix\n\
  73.   -V, --version-control WORD   override the usual version control\n\
  74.       --help                   display this help and exit\n\
  75.       --version                output version information and exit\n\
  76. \n\
  77. The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The\n\
  78. version control may be set with VERSION_CONTROL, values are:\n\
  79. \n\
  80.   t, numbered     make numbered backups\n\
  81.   nil, existing   numbered if numbered backups exist, simple otherwise\n\
  82.   never, simple   always make simple backups  \n");
  83.     }
  84.   exit (status);
  85. }
  86.  
  87. int
  88. is_ancestor (sb, ancestors)
  89.      struct stat *sb;
  90.      struct dir_list *ancestors;
  91. {
  92.   while (ancestors != 0)
  93.     {
  94.       if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev)
  95.     return 1;
  96.       ancestors = ancestors->parent;
  97.     }
  98.   return 0;
  99. }
  100.