DataMuseum.dk

Presents historical artifacts from the history of:

DKUUG/EUUG Conference tapes

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about DKUUG/EUUG Conference tapes

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download
Index: T t

⟦0b867f05d⟧ TextFile

    Length: 2365 (0x93d)
    Types: TextFile
    Names: »ttybiff.c«

Derivation

└─⟦2d1937cfd⟧ Bits:30007241 EUUGD22: P.P 5.0
    └─⟦dc59850a2⟧ »EurOpenD22/pp5.0/pp-5.tar.Z« 
        └─⟦e5a54fb17⟧ 
            └─⟦this⟧ »pp-5.0/Uip/rcvalert/ttybiff.c« 

TextFile

/* ttybiff.c: tty alert program using the UDP syntax stuff */

# ifndef lint
static char Rcsid[] = "@(#)$Header: /cs/research/pp/hubris/pp-beta/Uip/rcvalert/RCS/ttybiff.c,v 5.0 90/09/20 16:33:53 pp Exp Locker: pp $";
# endif

/*
 * $Header: /cs/research/pp/hubris/pp-beta/Uip/rcvalert/RCS/ttybiff.c,v 5.0 90/09/20 16:33:53 pp Exp Locker: pp $
 *
 * $Log:	ttybiff.c,v $
 * Revision 5.0  90/09/20  16:33:53  pp
 * rcsforce : 5.0 public release
 * 
 */



#include <stdio.h>
#include <isode/manifest.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
#include <utmp.h>
#include <sys/time.h>
#include <pwd.h>
#include <ctype.h>

#include "data.h"

char	username[40];
char	hostname[128];
char	homedir[512];
char	*filename = ".alert";
short	port = 0;
char	*extra = "NEW: ";
char	*format = "%extra(%size) %20from %subject << %50body";
int	width = 80;
int	debug = 0;
int	stdoutonly = 0;

char	*myname;

extern char	*index ();

main (argc, argv)
int	argc;
char	*argv[];
{
	extern char	*optarg;
	extern int	optind;
	int	opt;
	int	sd;

	myname = argv[0];
	while((opt = getopt(argc, argv, "f:p:u:s")) != EOF)
		switch (opt) {
		    case 's':
			stdoutonly = 1;
			break;
		    case 'f':
			filename = optarg;
			break;
		    case 'p':
			port = atoi(optarg);
			break;
		    case 'u':
			(void) strcpy (username, optarg);
			break;
		    default:
			fprintf (stderr,
				 "Usage: %s [-f file] [-p port] [-u user]",
				 myname);
			break;
		}
	argc -= optind;
	argv += optind;

	init_stuff ();

	sd = udp_start (port, filename, homedir);

	for (;;) {
		fd_set rfds;
		char	buffer[BUFSIZ];
		int	n;

		FD_ZERO (&rfds);
		FD_SET (sd, &rfds);
		if(select (sd + 1, &rfds, NULLFD, NULLFD,
			   (struct timeval *)0) <= 0)
			continue;

		n = sizeof (buffer) - 1;
		if (FD_ISSET (sd, &rfds) &&
		    getdata (sd, buffer, &n, username)) {
			buffer[n] = 0;
			if (stdoutonly ||
			    (notify_normal (buffer, username) == NOTOK &&
			    isatty (1)))
				printf ("\n\r%s%c\n\r",
					buffer, '\007');
		}
	}
}

init_stuff ()
{
	struct passwd *pwd;
	char	*cp, *getenv ();

	if ((pwd = getpwuid (getuid())) == NULL) {
		fprintf (stderr, "No user name\n");
		exit(-1);
	}
	if (username[0] == NULL)
		(void) strcpy (username, pwd -> pw_name);

	if ((cp = getenv ("HOME")) != NULL && *cp)
		(void) strcpy (homedir, cp);
	else
		(void) strcpy (homedir, pwd -> pw_dir);
}