diff --git a/ntfsprogs/ntfscat.8.in b/ntfsprogs/ntfscat.8.in index e69de29b..2d8896f5 100644 --- a/ntfsprogs/ntfscat.8.in +++ b/ntfsprogs/ntfscat.8.in @@ -0,0 +1,104 @@ +.\" -*- nroff -*- +.\" Copyright (c) 2003 Richard Russon. All Rights Reserved. +.\" This file may be copied under the terms of the GNU Public License. +.\" +.TH NTFSCAT 8 "October 2003" "Linux-NTFS version @VERSION@" +.SH NAME +ntfscat \- concatenate files and print them on the standard output +.SH SYNOPSIS +.B ntfscat +[ +.I options +] +.B device file +.SH DESCRIPTION +.B ntfscat +will read a file from an NTFS volume and display the contents on the standard output. +.PP +The case of the filename passed to +.B ntfscat +is ignored. +.SH OPTIONS +Below is a summary of all the options that +.B ntfscat +accepts. All options have two equivalent names. The short name is preceded by +.BR \- +and the long name is preceded by +.BR \-\- . +Any single letter options, that don't take an argument, can be combined into a +single command, e.g. +.BR \-fv +is equivalent to +.BR "\-f \-v" . +Long named options can be abbreviated to any unique prefix of their name. +.TP +.B \-f +.br +.ns +.TP +.B \-\-force +This will override some sensible defaults, such as not working with a mounted +volume. Use this option with caution. +.TP +.B \-h +.br +.ns +.TP +.B \-\-help +Show a list of options with a brief description of each one. +.TP +.B \-q +.br +.ns +.TP +.B \-\-quiet +Suppress some debug/warning/error messages. +.TP +.B \-V +.br +.ns +.TP +.B \-\-version +Show the version number, copyright and license +.BR ntfscat . +.TP +.B \-v +.br +.ns +.TP +.B \-\-vebose +Display more debug/warning/error messages. +.SH EXAMPLES +Display the contents of a file in the root of an NTFS volume. +.RS +.sp +.B ntfscat /dev/hda1 boot.ini +.sp +.RE +Display the contents of a file in a subdirectory of an NTFS volume. +.RS +.sp +.B ntfscat /dev/hda1 /winnt/system32/drivers/etc/hosts +.SH BUGS +.B ntfscat +was written in a short time, to get something "out there". It needs a lot more work. +If you find any bugs, please send an email to +.nh + +.hy +.SH AUTHOR +.B ntfscat +was written by Richard Russon (FlatCap) +.br +If you find this tool useful, make FlatCap happy and send him an email. +.SH AVAILABILITY +.B ntfscat +is part of the linux\-ntfs package and is available from +.br +.nh +http://linux\-ntfs.sourceforge.net/downloads.html +.hy +.SH SEE ALSO +.BR ntfsls (8), +.BR ntfsprogs (8) + diff --git a/ntfsprogs/ntfscat.c b/ntfsprogs/ntfscat.c index 99e61cff..13be2e24 100644 --- a/ntfsprogs/ntfscat.c +++ b/ntfsprogs/ntfscat.c @@ -2,6 +2,7 @@ * ntfscat - Part of the Linux-NTFS project. * * Copyright (c) 2003 Richard Russon + * Copyright (c) 2003 Anton Altaparmakov * * This utility will concatenate files and print on the standard output. * @@ -38,12 +39,10 @@ static const char *EXEC_NAME = "ntfscat"; static struct options opts; -static int verbose = 0; -static int quiet = 0; GEN_PRINTF (Eprintf, stderr, NULL, FALSE) -GEN_PRINTF (Vprintf, stdout, &verbose, TRUE) -GEN_PRINTF (Qprintf, stdout, &quiet, FALSE) +GEN_PRINTF (Vprintf, stdout, &opts.verbose, TRUE) +GEN_PRINTF (Qprintf, stdout, &opts.quiet, FALSE) /** * version - Print version information about the program @@ -71,8 +70,10 @@ void usage (void) { printf ("\nUsage: %s [options] device file\n" " -f --force Use less caution\n" + " -h --help Print this help\n" + " -q --quiet Less output\n" " -V --version Version information\n" - " -h --help Print this help\n\n", + " -v --verbose More output\n\n", //" -A --attribute Display this attribute", //" -I --file Display this file", //" -F --inode Display this inode", @@ -93,11 +94,13 @@ void usage (void) */ int parse_options (int argc, char **argv) { - static const char *sopt = "-fh?V"; // A:F:I:N: + static const char *sopt = "-fh?qVv"; // A:F:I:N: static const struct option lopt[] = { { "force", no_argument, NULL, 'f' }, { "help", no_argument, NULL, 'h' }, + { "quiet", no_argument, NULL, 'q' }, { "version", no_argument, NULL, 'V' }, + { "verbose", no_argument, NULL, 'v' }, // { "attribute", required_argument, NULL, 'A' }, // { "file", required_argument, NULL, 'F' }, // { "inode", required_argument, NULL, 'I' }, @@ -132,9 +135,15 @@ int parse_options (int argc, char **argv) case '?': help++; break; + case 'q': + opts.quiet++; + break; case 'V': ver++; break; + case 'v': + opts.verbose++; + break; default: Eprintf ("Unknown option '%s'.\n", argv[optind-1]); err++; @@ -143,6 +152,7 @@ int parse_options (int argc, char **argv) } if (help || ver) { + opts.quiet = 0; } else { if ((opts.device == NULL) || (opts.file == NULL)) { @@ -150,6 +160,12 @@ int parse_options (int argc, char **argv) Eprintf ("You must specify one device and one file.\n"); err++; } + + if (opts.quiet && opts.verbose) { + Eprintf("You may not use --quiet and --verbose at the " + "same time.\n"); + err++; + } } if (ver) diff --git a/ntfsprogs/ntfscat.h b/ntfsprogs/ntfscat.h index e69de29b..babd74f3 100644 --- a/ntfsprogs/ntfscat.h +++ b/ntfsprogs/ntfscat.h @@ -0,0 +1,40 @@ +/* + * ntfscat - Part of the Linux-NTFS project. + * + * Copyright (c) 2003 Richard Russon + * Copyright (c) 2003 Anton Altaparmakov + * + * This utility will concatenate files and print on the standard output. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program (in the main directory of the Linux-NTFS + * distribution in the file COPYING); if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef _NTFSCAT_H_ +#define _NTFSCAT_H_ + +#include "types.h" + +struct options { + char *device; /* Device/File to work with */ + char *file; /* File to display */ + int force; /* Override common sense */ + int quiet; /* Less output */ + int verbose; /* Extra output */ +}; + +#endif /* _NTFSCAT_H_ */ + +