home *** CD-ROM | disk | FTP | other *** search
/ PC-Online 1996 May / PCOnline_05_1996.bin / linux / source / a / bin / fileutil.12 / fileutil / fileutils-3.12 / src / cp-aux.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-01  |  3.1 KB  |  90 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. #include <config.h>
  21. #include <stdio.h>
  22.  
  23. #include "cp.h"
  24.  
  25. extern char *program_name;
  26.  
  27. void
  28. usage (status, reason)
  29.      int status;
  30.      char *reason;
  31. {
  32.   if (reason != NULL)
  33.     fprintf (status == 0 ? stdout : stderr, "%s: %s\n",
  34.          program_name, reason);
  35.  
  36.   if (status != 0)
  37.     fprintf (stderr, "Try `%s --help' for more information.\n",
  38.          program_name);
  39.   else
  40.     {
  41.       printf ("\
  42. Usage: %s [OPTION]... SOURCE DEST\n\
  43.   or:  %s [OPTION]... SOURCE... DIRECTORY\n\
  44. ",
  45.           program_name, program_name);
  46.       printf ("\
  47. \n\
  48.   -a, --archive                same as -dpr\n\
  49.   -b, --backup                 make backup before removal\n\
  50.   -d, --no-dereference         preserve links\n\
  51.   -f, --force                  remove existing destinations, never prompt\n\
  52.   -i, --interactive            prompt before overwrite\n\
  53.   -l, --link                   link files instead of copying\n\
  54.   -p, --preserve               preserve file attributes if possible\n\
  55.   -r                           copy recursively, non-directories as files\n\
  56.   -s, --symbolic-link          make symbolic links instead of copying\n\
  57.   -u, --update                 copy only older or brand new files\n\
  58.   -v, --verbose                explain what is being done\n\
  59.   -x, --one-file-system        stay on this file system\n\
  60.   -P, --parents                append source path to DIRECTORY\n\
  61.   -R, --recursive              copy directories recursively\n\
  62.   -S, --suffix=SUFFIX          override the usual backup suffix\n\
  63.   -V, --version-control=WORD   override the usual version control\n\
  64.       --help                   display this help and exit\n\
  65.       --version                output version information and exit\n\
  66. \n\
  67. The backup suffix is ~, unless set with SIMPLE_BACKUP_SUFFIX.  The\n\
  68. version control may be set with VERSION_CONTROL, values are:\n\
  69. \n\
  70.   t, numbered     make numbered backups\n\
  71.   nil, existing   numbered if numbered backups exist, simple otherwise\n\
  72.   never, simple   always make simple backups  \n");
  73.     }
  74.   exit (status);
  75. }
  76.  
  77. int
  78. is_ancestor (sb, ancestors)
  79.      struct stat *sb;
  80.      struct dir_list *ancestors;
  81. {
  82.   while (ancestors != 0)
  83.     {
  84.       if (ancestors->ino == sb->st_ino && ancestors->dev == sb->st_dev)
  85.     return 1;
  86.       ancestors = ancestors->parent;
  87.     }
  88.   return 0;
  89. }
  90.