source to "phone" system (part 1 of 4)

Jonathan C. Broome broome at ucbvax.BERKELEY.EDU
Sun Dec 29 18:38:29 AEST 1985


#-----cut here-----cut here-----cut here-----cut here-----
#! /bin/sh
# This is a shell archive, meaning:
# 1. Remove everything above the #! /bin/sh line.
# 2. Save the resulting text in a file.
# 3. Execute the file with /bin/sh (not csh) to create the files:
#	NOTE
#	READ_ME
#	phone.1
#	Makefile
#	common.h
# This archive created: Sat Dec 28 01:18:51 1985
export PATH; PATH=/bin:$PATH
echo shar: extracting "'NOTE'" '(2690 characters)'
if test -f 'NOTE'
then
	echo shar: will not over-write existing file "'NOTE'"
else
cat << \!Funky!Stuff! > 'NOTE'

Well, this is the first part of the source to my "phone" program, as promised.
I received quite a few responses, many with weird addresses, thus the posting 
instead of a mailing.  Be warned that this source is *not* a finished product, 
but more a "gamma test" version, although it has been running on a dozen UCB 
machines for several months and seems to work reasonably well.  For those of 
you who may feel compelled to hack on it, I have laced the sources with quite 
a few comments about possible improvements. I would also welcome any 
suggestions/code you may come up with.  Hopefully I will be able to send out 
a finished product sometime in the coming few months ... 

A few of the letters I received mentioned an interest in porting this to SysV
machines and such ... Good luck! (Last I heard, AT&T had just heard of IPC!)
This has only been tested on 4.[23] machines (Vax, Sun, and Perkin/Elmer), but
will hopefully be easy enough to port to other hardware. 

Installing phone: 

  Create an empty directory to put the sources in.  Unshar the archive files
by feeding to "sh"  (or use "unshar").  Run "make", then "make install" (use
"make -n" first if you're paranoid!)  Add "phone" to /etc/services, the line 
should look like:

	phone		1167/udp		# phone - conference calling (broome)

A note on port numbers: there is no need for phone to use priviledged port
numbers (think about it), and it would really be best for you to stick with 
port 1167 (what we use at Berkeley), at least if you want to be able to 
communicate with the outside world.  I am working on an rfc-type spec in 
order to get a legitimately-assigned port number, but it will take a little 
while, so let's use 1167, okay? 

Back to installation:  If your site runs the inetd, also add this line to
/etc/services:

	phone	dgram	udp	wait	root	/etc/phoned	phoned

Finally,  if you do not use inetd, start up the phoned by typing "/etc/phoned",
else do a "ps ax | grep inetd" to find inetd's pid, then kill -HUP pid to have 
it reread the config file.

The manual page is presently pretty skimpy, so you may want to look at the
routines in kb.c and cmd.c to get some idea as to what is going on.
(Brownie points to anyone who writes a better man page!)


For those of you with arpanet access, the sources will also be available in
 ~ftp/pub/phone.tar on ucbvax for your ftp'ing enjoyment.

Good luck, and enjoy!

==============================================================================
 Jonathan C. Broome                      University of California at Berkeley
    ...!ucbvax!broome
   broome at ucb-vax.berkeley.edu
==============================================================================

!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'READ_ME'" '(1102 characters)'
if test -f 'READ_ME'
then
	echo shar: will not over-write existing file "'READ_ME'"
else
cat << \!Funky!Stuff! > 'READ_ME'
Stuff for installing phone:                                    22 Dec 1985
===========================                                    ===========

Phone consists of three parts - the client ("phone"), the master daemon 
("phoned"), and the conversation daemon ("convd").

"Phoned" is the master server on each machine.  It receives requests from
the client process and acts on them.  Its main purpose is to receive,
store, and process call requests.  All communication to phoned is through
udp/ip datagrams.  The master daemon can be compiled to run standalone or 
under the inetd as a single-threaded datagram-oriented server. 

The conversation daemon is invoked by the master daemon when a user requests
a conversation. Its purpose is simply to relay what each person types back
to all the others in a single conversation.  Each user connects to the convd
over a tcp/ip stream connection, and the convd reads a buffer from each
client and resends the buffer to the other users.

"Phone" is the user client program, responsible for managing windows and
sending control packets to request calls.

!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'phone.1'" '(4210 characters)'
if test -f 'phone.1'
then
	echo shar: will not over-write existing file "'phone.1'"
else
cat << \!Funky!Stuff! > 'phone.1'
.TH PHONE 1
.UC 5
.SH NAME
phone \- communicate with other users in real-time
.SH SYNOPSIS
phone [ user at host [tty] ]
.SH DESCRIPTION
\fIPhone\fR allows for two or more people to interact in 
a conversation across a machine or network, providing a form 
of conference calling.
Each participant has a window in which to type. The first line
of each window is a header showing who is in the window, like:
.sp 1
.nf 
.in +3
---- root at cory on console (Commodore Cory) --------------
.in -3
.fi
.sp 1
The login name and tty are automatically determined, and the
real name is taken from the password file, which may be overridden
by setting the \fINAME\fR environment variable (see \fIcsh\fR(1) for
further details.)
Users may join or leave a conversation at any point in time, and the
windows will be automatically resized and redrawn.
.SH USAGE
When you are being paged by another person, a message like this will 
appear on your screen:
.br
.sp 1
.nf
.in +5
Message from the Telephone_Operator at host at time ...
phone: connection requested by user at host
phone: respond with "phone user at host"
.in -5
.sp 1
.fi
You may answer the phone simply by typing "phone", which will 
answer the pending call, and connect you directly.
.br
.sp 1
\fIPhone\fR has two \fImodes\fR, much like the \fIvi\fR editor.  These
two modes are called \fIconversation\fR and \fIcommand\fR modes, and
are toggled through the escape (<esc>) and return (<ret>) keys.
.br
.sp 1
When in the \fIconversation\fR mode, anything typed
on the keyboard is sent to everyone in the current conversation.  This
is the default mode.
.br
.sp 1
The \fIcommand\fR mode is used to execute commands, and is entered by 
pressing the escape key. When in this mode, \fIphone\fR will clear
the bottom line of the screen and print the prompt "Command>".  
At this point anything typed in is
added to the command buffer, and will be executed when the return key
is pressed.  To exit command mode without executing the acommand,
press the escape key a second time.
.br
.sp 1
To ivite another user to join the current conversation from within \fIphone\fP,
enter command  mode by pressing the escape key, then type
.br
.sp 1
.in +5
call \fIuser at host\fR
.in -5
.sp 1
followed by the <return> key. 
The user will receive a message like the one shown above if
he is logged in. 
The \fIhost\fR part of the name may be omitted if the
both you and the other person are on the same machine.
.br
.sp 1
\fIPhone\fR also allows a user to execute shell commands inside his window 
with any keyboard input being fed to the process.  The program's output
is sent to all users in the conversation.
A shell command is executed within \fIphone\fR through the use of
the \fIrun\fR or \fI!\fR command.  An example of this is:
.br
.sp 1
.in +5
run adb a.out core
.in -5
.sp 1
to run the \fIadb\fR command with the arguments \fIa.out\fR and \fIcore\fR.
Note that tilde expansion (ie. ~user) is done by \fIphone\fR, but
wildcarding, piping, and i/o redirection are performed by the user's shell.
It is unlikely that anyone actually cares, of course.
Also, the use of
visually-oriented programs such as \fIvi\fR and \fIrogue\fR is not
recommended, as this usually results in strange and unpredictable things 
happening. If your terminal goes up in a puff of smoke, you were warned.
.br
.sp 1
To find about the other commands available with \fIphone\fR, type
\fIhelp\fR or \fI?\fR in command mode.
.PP
You can allow or disallow \fIphone\fR messages to your terminal through 
the use of the \fImesg\fR command.  When you first log on, messages are enabled.
.SH BUGS
\fICsh\fR is unhappy being fed through pipes, but it's a dumb program anyway.
.br
The manual page is horrendous at best.
.br
Please send any problems, questions, or suggestions to the author.
.SH AUTHOR
Jonathan C. Broome (broome at ucb-vax.berkeley.edu)
.br
The original user interface is borrowed from a previous program (also 
called \fIphone\fR) posted to the network in late 1984, author unknown.
.SH FILES
.ta \w'/etc/passwd      'u
.br
/etc/hosts	to find the recipient's machine
.br
/etc/utmp	to find the recipient's tty
.br
/etc/passwd	to find each user's real name
.SH "SEE ALSO"
mail(1), mesg(1), talk(1), who(1), write(1)
!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'Makefile'" '(310 characters)'
if test -f 'Makefile'
then
	echo shar: will not over-write existing file "'Makefile'"
else
cat << \!Funky!Stuff! > 'Makefile'
#
#  Master makefile for the phone program         18 December 1985
#
#  You'll need to edit the makefile in each of the subdirectories
#  to change the compilation flags.
# 

DIRS	=	client master conv

.DEFAULT:	
	for i in ${DIRS} ; do \
		cd $$i ; make MFLAGS="${MFLAGS}" $@ ; cd .. ; \
	done

default: all	
!Funky!Stuff!
fi # end of overwriting check
echo shar: extracting "'common.h'" '(1266 characters)'
if test -f 'common.h'
then
	echo shar: will not over-write existing file "'common.h'"
else
cat << \!Funky!Stuff! > 'common.h'
/*
 *   Defines common to all the parts of the phone system.
 */


#ifndef		ESC
#define		ESC			'\033'		/* precedes all commands */
#endif

#define		ACK			'y'			/* good response code */
#define		NAK			'n'			/* not-so-good code   */

/*
 *   Commands sent from conversation daemon to client.
 */
 
#define		META		0200			/* high bit for command characters */
#define		ADDUSER		(01<<5)			/* add a user to the conversation  */
#define		DELUSER		(02<<5)			/* delete a user from conversation */
#define		UPDATE		(03<<5)			/* set screen update mode */

/*
 *   Commands sent from or master daemon to client.
 */

#define		MESSAGE		'M'				/* following is message text       */

/*
 *   Commands sent by client to conversation or master daemons.
 */

#define		ANSWER		'A'			/* he got the invite, will answer  */
#define		CALLING		'C'			/* daemon is calling the user      */
#define		PAGE		'P'			/* page a user                     */
#define		INQUIRE		'I'			/* inquire as to whether invited   */
#define		REINVITE	'R'			/* renew a request for paging      */
#define		DAEMON		'D'			/* create a daemon for me          */
#define		WHO			'W'			/* tell me who's on ...            */
#define		KILL		'K'			/* cause the daemon to exit        */

#ifndef PORT
#define		PORT	1167
#endif
!Funky!Stuff!
fi # end of overwriting check
#	End of shell archive
exit 0



More information about the Comp.sources.unix mailing list