Allow the use of `-' as an argument to the -w option so that standard

input may be used (e.g. gunzip -c /var/log/wtmp.Jan.gz | ac -w - ).

PR:	12467
Submitted by:	wollman
This commit is contained in:
Sheldon Hearn 1999-06-30 21:46:03 +00:00
parent df8abd0bb9
commit 2835cbd026
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=48378
2 changed files with 18 additions and 7 deletions

View File

@ -28,7 +28,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.\" $Id: ac.8,v 1.9 1997/02/22 16:01:10 peter Exp $
.\" $Id: ac.8,v 1.10 1997/09/01 06:11:40 charnier Exp $
.\"
.Dd March 15, 1994
.Dt AC 8
@ -84,6 +84,9 @@ Read connect time data from
.Ar wtmp
instead of the default file,
.Pa /var/log/wtmp .
If
.Ql \&-
is specified, read records from the standard input.
.It Ar users ...
Display totals for the given individuals only.
.El

View File

@ -15,7 +15,7 @@
#ifndef lint
static const char rcsid[] =
"$Id: ac.c,v 1.9 1998/05/25 05:21:29 steve Exp $";
"$Id: ac.c,v 1.10 1998/07/02 05:34:08 phk Exp $";
#endif /* not lint */
#include <sys/types.h>
@ -106,12 +106,20 @@ file(name)
{
FILE *fp;
if ((fp = fopen(name, "r")) == NULL)
err(1, "%s", name);
/* in case we want to discriminate */
if (strcmp(_PATH_WTMP, name))
/*
* Added by GAW...
*/
if (strcmp("-", name) == 0) {
Flags |= AC_W;
return fp;
return (stdin);
} else {
if ((fp = fopen(name, "r")) == NULL)
err(1, "%s", name);
/* in case we want to discriminate */
if (strcmp(_PATH_WTMP, name))
Flags |= AC_W;
return fp;
}
}
struct tty_list *