-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f26d483
commit 0dd0c18
Showing
7 changed files
with
945 additions
and
939 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,11 @@ Change log for duff | |
|
||
Maintained since version 0.3.1. | ||
|
||
2015-08-13 Camilla Berglund <[email protected]> | ||
|
||
* duff.c duff.h duffdriver.c dufffile.c duffstring.c duffstring.h duffutil.c: | ||
Changed indent width. | ||
|
||
2013-09-13 Camilla Berglund <[email protected]> | ||
|
||
* duffutil.c (set_digest_function): Changed to accept a string. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,53 +23,53 @@ | |
*/ | ||
|
||
#if HAVE_CONFIG_H | ||
#include "config.h" | ||
#include "config.h" | ||
#endif | ||
|
||
#if HAVE_SYS_TYPES_H | ||
#include <sys/types.h> | ||
#include <sys/types.h> | ||
#endif | ||
|
||
#if HAVE_SYS_STAT_H | ||
#include <sys/stat.h> | ||
#include <sys/stat.h> | ||
#endif | ||
|
||
#if HAVE_SYS_PARAM_H | ||
#include <sys/param.h> | ||
#include <sys/param.h> | ||
#endif | ||
|
||
#if HAVE_INTTYPES_H | ||
#include <inttypes.h> | ||
#include <inttypes.h> | ||
#elif HAVE_STDINT_H | ||
#include <stdint.h> | ||
#include <stdint.h> | ||
#endif | ||
|
||
#if HAVE_ERRNO_H | ||
#include <errno.h> | ||
#include <errno.h> | ||
#endif | ||
|
||
#if HAVE_UNISTD_H | ||
#include <unistd.h> | ||
#include <unistd.h> | ||
#endif | ||
|
||
#if HAVE_STDIO_H | ||
#include <stdio.h> | ||
#include <stdio.h> | ||
#endif | ||
|
||
#if HAVE_STRING_H | ||
#include <string.h> | ||
#include <string.h> | ||
#endif | ||
|
||
#if HAVE_STDLIB_H | ||
#include <stdlib.h> | ||
#include <stdlib.h> | ||
#endif | ||
|
||
#if HAVE_LIMITS_H | ||
#include <limits.h> | ||
#include <limits.h> | ||
#endif | ||
|
||
#if HAVE_LOCALE_H | ||
#include <locale.h> | ||
#include <locale.h> | ||
#endif | ||
|
||
#include "duffstring.h" | ||
|
@@ -149,154 +149,154 @@ static void bugs(void); | |
*/ | ||
static void version(void) | ||
{ | ||
printf("%s\n", PACKAGE_STRING); | ||
printf(_("Copyright (c) 2005 Camilla Berglund <[email protected]>\n")); | ||
printf(_("%s contains shaX-asaddi\n"), PACKAGE_NAME); | ||
printf(_("Copyright (c) 2001-2003 Allan Saddi <[email protected]>\n")); | ||
printf("%s\n", PACKAGE_STRING); | ||
printf(_("Copyright (c) 2005 Camilla Berglund <[email protected]>\n")); | ||
printf(_("%s contains shaX-asaddi\n"), PACKAGE_NAME); | ||
printf(_("Copyright (c) 2001-2003 Allan Saddi <[email protected]>\n")); | ||
} | ||
|
||
/* Prints brief help information to stdout. | ||
* Note that it is a good idea to keep this synchronised with the actual code. | ||
* Note that it is also a good idea it keep it synchronised with the manpage. | ||
* NOTE: It is a good idea to keep this synchronised with the actual code. | ||
* NOTE: It is also a good idea it keep it synchronised with the manpage. | ||
*/ | ||
static void usage(void) | ||
{ | ||
printf(_("Usage: %s [-0DHLPaepqrtuz] [-d function] [-f format] [-l size] [file ...]\n"), | ||
printf(_("Usage: %s [-0DHLPaepqrtuz] [-d function] [-f format] [-l size] [file ...]\n"), | ||
PACKAGE_NAME); | ||
|
||
printf(" %s -h\n", PACKAGE_NAME); | ||
printf(" %s -v\n", PACKAGE_NAME); | ||
|
||
printf(_("Options:\n")); | ||
printf(_(" -0 read and write file names terminated by a null character\n")); | ||
printf(_(" -D only report files as duplicate if they are on the same device\n")); | ||
printf(_(" -H follow symbolic links to directories on the command line\n")); | ||
printf(_(" -L follow all symbolic links to directories\n")); | ||
printf(_(" -P do not follow any symbolic links (default)\n")); | ||
printf(_(" -a include hidden files when searching recursively\n")); | ||
printf(_(" -d the message digest function to use: sha1 sha256 sha384 sha512\n")); | ||
printf(_(" -e excess mode; list all but one file from each cluster (no headers)\n")); | ||
printf(_(" -f format for cluster headers\n")); | ||
printf(_(" -h show this help\n")); | ||
printf(_(" -l the minimum size that activates sampling\n")); | ||
printf(_(" -q quiet; suppress warnings and error messages\n")); | ||
printf(_(" -p physical files; do not report multiple hard links as duplicates\n")); | ||
printf(_(" -r search recursively through specified directories\n")); | ||
printf(_(" -t thorough; force byte-by-byte comparison of files\n")); | ||
printf(_(" -u unique mode; list unique files instead of duplicates\n")); | ||
printf(_(" -v show version information\n")); | ||
printf(_(" -z do not report empty files\n")); | ||
printf(" %s -h\n", PACKAGE_NAME); | ||
printf(" %s -v\n", PACKAGE_NAME); | ||
|
||
printf(_("Options:\n")); | ||
printf(_(" -0 read and write file names terminated by a null character\n")); | ||
printf(_(" -D only report files as duplicate if they are on the same device\n")); | ||
printf(_(" -H follow symbolic links to directories on the command line\n")); | ||
printf(_(" -L follow all symbolic links to directories\n")); | ||
printf(_(" -P do not follow any symbolic links (default)\n")); | ||
printf(_(" -a include hidden files when searching recursively\n")); | ||
printf(_(" -d the message digest function to use: sha1 sha256 sha384 sha512\n")); | ||
printf(_(" -e excess mode; list all but one file from each cluster (no headers)\n")); | ||
printf(_(" -f format for cluster headers\n")); | ||
printf(_(" -h show this help\n")); | ||
printf(_(" -l the minimum size that activates sampling\n")); | ||
printf(_(" -q quiet; suppress warnings and error messages\n")); | ||
printf(_(" -p physical files; do not report multiple hard links as duplicates\n")); | ||
printf(_(" -r search recursively through specified directories\n")); | ||
printf(_(" -t thorough; force byte-by-byte comparison of files\n")); | ||
printf(_(" -u unique mode; list unique files instead of duplicates\n")); | ||
printf(_(" -v show version information\n")); | ||
printf(_(" -z do not report empty files\n")); | ||
} | ||
|
||
/* Prints bug report address to stdout. | ||
*/ | ||
static void bugs(void) | ||
{ | ||
printf(_("Report bugs to <%s>\n"), PACKAGE_BUGREPORT); | ||
printf(_("Report bugs to <%s>\n"), PACKAGE_BUGREPORT); | ||
} | ||
|
||
/* I don't know what this function does. | ||
* I just put it in because it looks cool. | ||
*/ | ||
int main(int argc, char** argv) | ||
{ | ||
int ch; | ||
char* temp; | ||
off_t limit; | ||
int ch; | ||
char* temp; | ||
off_t limit; | ||
|
||
setlocale(LC_ALL, ""); | ||
bindtextdomain(PACKAGE, LOCALEDIR); | ||
textdomain(PACKAGE); | ||
setlocale(LC_ALL, ""); | ||
bindtextdomain(PACKAGE, LOCALEDIR); | ||
textdomain(PACKAGE); | ||
|
||
while ((ch = getopt(argc, argv, "0DHLPad:ef:hl:pqrtuvz")) != -1) | ||
{ | ||
switch (ch) | ||
while ((ch = getopt(argc, argv, "0DHLPad:ef:hl:pqrtuvz")) != -1) | ||
{ | ||
case '0': | ||
null_terminate_flag = 1; | ||
break; | ||
case 'D': | ||
same_device_flag = 1; | ||
break; | ||
case 'H': | ||
follow_links_mode = ARG_SYMLINKS; | ||
break; | ||
case 'L': | ||
follow_links_mode = ALL_SYMLINKS; | ||
break; | ||
case 'P': | ||
follow_links_mode = NO_SYMLINKS; | ||
break; | ||
case 'a': | ||
all_files_flag = 1; | ||
break; | ||
case 'd': | ||
if (set_digest_function(optarg) != 0) | ||
error(_("%s is not a supported digest function"), optarg); | ||
break; | ||
case 'e': | ||
excess_flag = 1; | ||
break; | ||
case 'f': | ||
header_format = optarg; | ||
break; | ||
case 'h': | ||
usage(); | ||
bugs(); | ||
exit(EXIT_SUCCESS); | ||
case 'l': | ||
limit = (off_t) strtoull(optarg, &temp, 10); | ||
if (temp == optarg || errno == ERANGE || errno == EINVAL) | ||
warning(_("Ignoring invalid sample limit %s"), optarg); | ||
else | ||
sample_limit = limit; | ||
break; | ||
case 'p': | ||
physical_flag = 1; | ||
break; | ||
case 'q': | ||
quiet_flag = 1; | ||
break; | ||
case 'r': | ||
recursive_flag = 1; | ||
break; | ||
case 't': | ||
thorough_flag = 1; | ||
break; | ||
case 'u': | ||
unique_files_flag = 1; | ||
break; | ||
case 'v': | ||
version(); | ||
exit(EXIT_SUCCESS); | ||
case 'z': | ||
ignore_empty_flag = 1; | ||
break; | ||
default: | ||
usage(); | ||
bugs(); | ||
exit(EXIT_FAILURE); | ||
switch (ch) | ||
{ | ||
case '0': | ||
null_terminate_flag = 1; | ||
break; | ||
case 'D': | ||
same_device_flag = 1; | ||
break; | ||
case 'H': | ||
follow_links_mode = ARG_SYMLINKS; | ||
break; | ||
case 'L': | ||
follow_links_mode = ALL_SYMLINKS; | ||
break; | ||
case 'P': | ||
follow_links_mode = NO_SYMLINKS; | ||
break; | ||
case 'a': | ||
all_files_flag = 1; | ||
break; | ||
case 'd': | ||
if (set_digest_function(optarg) != 0) | ||
error(_("%s is not a supported digest function"), optarg); | ||
break; | ||
case 'e': | ||
excess_flag = 1; | ||
break; | ||
case 'f': | ||
header_format = optarg; | ||
break; | ||
case 'h': | ||
usage(); | ||
bugs(); | ||
exit(EXIT_SUCCESS); | ||
case 'l': | ||
limit = (off_t) strtoull(optarg, &temp, 10); | ||
if (temp == optarg || errno == ERANGE || errno == EINVAL) | ||
warning(_("Ignoring invalid sample limit %s"), optarg); | ||
else | ||
sample_limit = limit; | ||
break; | ||
case 'p': | ||
physical_flag = 1; | ||
break; | ||
case 'q': | ||
quiet_flag = 1; | ||
break; | ||
case 'r': | ||
recursive_flag = 1; | ||
break; | ||
case 't': | ||
thorough_flag = 1; | ||
break; | ||
case 'u': | ||
unique_files_flag = 1; | ||
break; | ||
case 'v': | ||
version(); | ||
exit(EXIT_SUCCESS); | ||
case 'z': | ||
ignore_empty_flag = 1; | ||
break; | ||
default: | ||
usage(); | ||
bugs(); | ||
exit(EXIT_FAILURE); | ||
} | ||
} | ||
} | ||
|
||
argc -= optind; | ||
argv += optind; | ||
argc -= optind; | ||
argv += optind; | ||
|
||
if (!header_format) | ||
{ | ||
if (thorough_flag) | ||
header_format = _("%n files in cluster %i (%s bytes)"); | ||
else | ||
header_format = _("%n files in cluster %i (%s bytes, digest %d)"); | ||
} | ||
if (!header_format) | ||
{ | ||
if (thorough_flag) | ||
header_format = _("%n files in cluster %i (%s bytes)"); | ||
else | ||
header_format = _("%n files in cluster %i (%s bytes, digest %d)"); | ||
} | ||
|
||
header_uses_digest = cluster_header_uses_digest(header_format); | ||
header_uses_digest = cluster_header_uses_digest(header_format); | ||
|
||
if (thorough_flag && header_uses_digest) | ||
error(_("Digest (%%d) is not calculated when using -t")); | ||
if (thorough_flag && header_uses_digest) | ||
error(_("Digest (%%d) is not calculated when using -t")); | ||
|
||
process_args(argc, argv); | ||
process_args(argc, argv); | ||
|
||
exit(EXIT_SUCCESS); | ||
exit(EXIT_SUCCESS); | ||
} | ||
|
Oops, something went wrong.