Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 2 Apr 1999 17:40:55 -0500 (EST)
From:      James Howard <howardjp@byzantine.student.umd.edu>
To:        FreeBSD-gnats-submit@freebsd.org
Subject:   bin/10924: Extensions to biff(1)
Message-ID:  <199904022240.RAA08430@byzantine.student.umd.edu>

next in thread | raw e-mail | index | archive | help

>Number:         10924
>Category:       bin
>Synopsis:       Extensions to biff(1)
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr  2 14:40:00 PST 1999
>Closed-Date:
>Last-Modified:
>Originator:     James Howard
>Release:        FreeBSD 4.0-CURRENT i386
>Organization:
University of Maryland
>Environment:

	FreeBSD byzantine.student.umd.edu 4.0-CURRENT FreeBSD 4.0-CURRENT #2: Thu Apr  1 00:29:18 EST 1999     howardjp@byzantine.student.umd.edu:/usr/src/sys/compile/BYZANTINE  i386

>Description:

	Long ago, under Linux, I needed to be able to change the status of
    mail notification on a terminal which I was not using (for instance,
    I was downloading a large file under Lynx and notifications messed
    up the status line).  Without the source handy, I reimplmented 
    biff(1) from scratch with the new functionality.  I later brought
    these over to FreeBSD when I started (around 2.2.2).  It also
    implements a quiet mode for simply checking on the status.

>How-To-Repeat:

	

>Fix:
	
    Below is a shar archive containing a completely reimplmented 
    biff(1) as well as an updated man page, neither are diffs, 
    although the man page should be.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	biff.1
#	biff.c
#
echo x - biff.1
sed 's/^X//' >biff.1 << 'END-of-biff.1'
X.\" Copyright (c) 1980, 1990, 1993
X.\"	The Regents of the University of California.  All rights reserved.
X.\"
X.\" Redistribution and use in source and binary forms, with or without
X.\" modification, are permitted provided that the following conditions
X.\" are met:
X.\" 1. Redistributions of source code must retain the above copyright
X.\"    notice, this list of conditions and the following disclaimer.
X.\" 2. Redistributions in binary form must reproduce the above copyright
X.\"    notice, this list of conditions and the following disclaimer in the
X.\"    documentation and/or other materials provided with the distribution.
X.\" 3. All advertising materials mentioning features or use of this software
X.\"    must display the following acknowledgement:
X.\"	This product includes software developed by the University of
X.\"	California, Berkeley and its contributors.
X.\" 4. Neither the name of the University nor the names of its contributors
X.\"    may be used to endorse or promote products derived from this software
X.\"    without specific prior written permission.
X.\"
X.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
X.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
X.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X.\" SUCH DAMAGE.
X.\"
X.\"     @(#)biff.1	8.1 (Berkeley) 6/6/93
X.\"	$Id: biff.1,v 1.2 1996/08/03 14:25:02 wosch Exp $
X.\"
X.Dd June 6, 1993
X.Dt BIFF 1
X.Os
X.Sh NAME
X.Nm biff
X.Nd "be notified if mail arrives and who it is from"
X.Sh SYNOPSIS
X.Nm biff
X.Op Fl q
X.Op Fl t Ar tty
X.Op Cm ny
X.Sh DESCRIPTION
X.Nm Biff
Xinforms the system whether you want to be notified when mail arrives
Xduring the current terminal session.
X.Pp
XOptions supported by
X.Nm biff :
X.Bl -tag -width 8n
X.It Fl q
XSuppress all output.
X.It Fl t Ar tty
XSet notification status of
X.Ar tty
Xrather than the current tty.
X.It Cm n
XDisables notification.
X.It Cm y
XEnables notification.
X.El
X.Pp
XWhen mail notification is enabled, the header and first few lines of
Xthe message will be printed on your screen whenever mail arrives.
XA
X.Dq Li biff y
Xcommand is often included in the file
X.Pa \&.login
Xor
X.Pa \&.profile
Xto be executed at each login.
X.Pp
X.Nm Biff
Xoperates asynchronously.
XFor synchronous notification use the
X.Ar MAIL
Xvariable of
X.Xr sh 1
Xor the
X.Ar mail
Xvariable of
X.Xr csh 1 .
X.Sh SEE ALSO
X.Xr csh 1 ,
X.Xr mail 1 ,
X.Xr sh 1 ,
X.Xr comsat 8
X.Sh HISTORY
XThe
X.Nm
Xcommand appeared in 
X.Bx 4.0 .
XIt was name after the dog of Heidi Stettner. He died
Xin August 1993, at 15.
END-of-biff.1
echo x - biff.c
sed 's/^X//' >biff.c << 'END-of-biff.c'
X/*-
X * Copyright (c) 1999 James Howard (howardjp@wam.umd.edu)
X * All rights reserved.
X *
X * Redistribution and use in source and binary forms, with or without
X * modification, are permitted provided that the following conditions
X * are met:
X * 1. Redistributions of source code must retain the above copyright
X *    notice, this list of conditions and the following disclaimer.
X * 2. Redistributions in binary form must reproduce the above copyright
X *    notice, this list of conditions and the following disclaimer in the
X *    documentation and/or other materials provided with the distribution.
X *
X * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
X * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
X * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
X * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
X * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
X * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
X * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
X * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
X * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
X * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
X * SUCH DAMAGE.
X */
X
X/*
X *  Biff(1) toggles the owner-execute permissions on a user's tty.  When
X *  the permissions are on, comsat will notify the user upon receipt of
X *  email.  
X */
X
X#include <errno.h>
X#include <paths.h>
X#include <stdlib.h>
X#include <stdio.h>
X#include <unistd.h>
X#include <sys/stat.h>
X
Xstatic void usage();
X
Xvoid main(int argc, char *argv[]) 
X{
X  struct stat buf;
X  int ch, quiet = 0;
X  char *status = NULL, *tty;
X  
X  /*  Sets the default terminal to the current standard error.  */
X  tty = ttyname(STDERR_FILENO);
X  while ((ch = getopt(argc, argv, "qt:?")) != EOF)
X    switch(ch) {
X    case 'q':
X      quiet = 1;
X      break;
X    case 't':
X      tty = optarg;
X      break;
X    case '?':
X      usage();
X    }
X  while (--argc != 0)
X    if (argv[argc][0] != '-' && argv[argc] != tty)
X      status = argv[argc];
X  /* 
X   *  Moves to the device directory so that calls such as ``mesg -t
X   *  ttyp0'' work without having to prepend the directory name.
X   */
X  (void)chdir(_PATH_DEV);
X  if(stat(tty, &buf) != 0) {
X    if(!quiet)
X      warn(tty);
X    exit(2);
X  }
X  if(status == NULL) {
X    if(buf.st_mode & S_IEXEC) {
X      if(!quiet)
X        (void)fprintf(stderr, "is y\n");
X      exit(0);
X    }
X    if(!quiet)
X      (void)fprintf(stderr, "is n\n");
X    exit(1);
X  }		
X  
X  /*  By checking status[0], "y", "yes", "yummy", etc., all are 'y'  */
X  if(status[0] == 'y') {
X    if(chmod(tty, buf.st_mode | S_IEXEC) != 0) {
X      if(!quiet) 
X        warn(tty);
X      exit(2);
X    }
X    exit(0);
X  }
X  if(status[0] == 'n') {
X    if(chmod(tty, buf.st_mode & ~S_IEXEC) != 0) {
X      if(!quiet)
X        warn(tty);
X      exit(2);
X    }
X    exit(1);
X  }
X  /*  
X   *  This is only reached if the user entered an invalid parameter 
X   *  for the new status of the tty.
X   */
X  exit(2);
X}
X
Xvoid usage() {
X  
X  (void)fprintf(stderr, "\
Xusage: biff [-q] [-t tty] [y | n]\n\
X\t-q		-- quiet mode, suppress all output\n\
X\t-t tty		-- specify the tty to check/modify\n");
X  exit(2);
X}
END-of-biff.c
exit




>Release-Note:
>Audit-Trail:
>Unformatted:


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199904022240.RAA08430>