[alt.sources] slugnet - multiple user conferencing system: Part 1/6

purdon@athena.mit.edu (James R. Purdon III) (12/21/90)

The slugnet program is a multiple-user, interactive conferencing
facility.  It currently runs under a variety of System V-based and
BSD-based operating systems (although certain functions may not be
possible under some of these operating systems).

Cut here-------------------------------------------------------------------
#!/bin/sh
# to extract, remove the header and type "sh filename"
if `test ! -s ./slugnetd.1`
then
echo "writing ./slugnetd.1"
cat > ./slugnetd.1 << '\End\Of\Shar\'
\" @(#)slugnetd.1	1.1
TH slugnetd 1
SH NAME
slugnetd \- slugnet network server, a multiple\-user, interactive
conferencing system
SH SYNTAX
B slugnetd
SH DESCRIPTION
NXR "slugnetd"
NXA "multiple\-user" "interactive" "conferencing" "system"
NXA "network" "slugnet program"
NXR "message" "interactive"
The
PN slugnetd
is a network server for the slugnet multiple\-user conferencing system.
With 
PN slugnetd
running, users do not require logins on the system in order to use the
PN slugnet
conferencing system.
PP 
Remote users can connect to the system running
PN slugnetd
by issuing the command :
EX
telnet host 2727
EE
where host is the name of the system running slugnetd.
PP
PN slugnetd
should probably be placed in the system startup scripts.
SH RESTRICTIONS
The number of users which can be serviced is limited to the maximum
number of processes the owner of slugnetd may simultaneously have
executing, and 
PN slugnetd
users may not be able to execute all of the commands that can be executed by
PN slugnet
users.
PP
SH "SEE ALSO"
slugnet(1),telnet(1c)
\End\Of\Shar\
else
  echo "will not over write ./slugnetd.1"
fi
chmod 400 ./slugnetd.1
if [ `wc -c ./slugnetd.1 | awk '{printf $1}'` -ne 1083 ]
then
echo `wc -c ./slugnetd.1 | awk '{print "Got " $1 ", Expected " 1083}'`
fi
if `test ! -s ./strnicmp.c`
then
echo "writing ./strnicmp.c"
cat > ./strnicmp.c << '\End\Of\Shar\'
/* @(#)strnicmp.c	1.2 */
#include "slugnet.h" 

int strnicmp(s1,s2,len)

/* compares s1 and s2, ignoring case */

char s1[],s2[];
int len;
{
        char *ds1,*ds2,*malloc();
        int i,ls1,ls2;
#ifdef SYSV2
        void free();
#endif SYSV2
#ifdef SYSV3
        void free();
#endif SYSV3
#ifdef ULTRIX
        void free();
#endif ULTRIX

        ls1=strlen(s1)+1;
        ds1=malloc((unsigned)ls1);
        ls2=strlen(s2)+1;
        ds2=malloc((unsigned)ls2);
        strcpy(ds1,s1);
        strcpy(ds2,s2);
        lower(ds1);
        lower(ds2);
        i=strncmp(ds1,ds2,len);
        free(ds2);
        free(ds1);
        return(i);
}
\End\Of\Shar\
else
  echo "will not over write ./strnicmp.c"
fi
chmod 400 ./strnicmp.c
if [ `wc -c ./strnicmp.c | awk '{printf $1}'` -ne 643 ]
then
echo `wc -c ./strnicmp.c | awk '{print "Got " $1 ", Expected " 643}'`
fi
if `test ! -s ./task.c`
then
echo "writing ./task.c"
cat > ./task.c << '\End\Of\Shar\'
/* @(#)task.c	1.3 */
#ifdef NETWORK
#include "net.h"

/* pass socket descriptor to real application */

void task( s )
int s;
{
	slugnet( s, (char *)NULL );	
	shutdown( s, 2 );
	close( s );
}
#endif NETWORK
\End\Of\Shar\
else
  echo "will not over write ./task.c"
fi
chmod 400 ./task.c
if [ `wc -c ./task.c | awk '{printf $1}'` -ne 207 ]
then
echo `wc -c ./task.c | awk '{print "Got " $1 ", Expected " 207}'`
fi
if `test ! -s ./transmit.c`
then
echo "writing ./transmit.c"
cat > ./transmit.c << '\End\Of\Shar\'
/* @(#)transmit.c	1.3 */
#include "slugnet.h"

int transmit(socket,string,crlf)

/* transmits a string to the output units */


char string[];
int crlf;
int socket;
{
	char *sp;
        int err, i,len;
        len=strlen(string);
	sp = string;
        for(i=0;i<len;i++)
        {
                if(socket==NULL)
#ifdef SYSV3
                                putchar((int)((char)string[i]));
#endif SYSV3
#ifdef SYSV2
                                putchar((int)((char)string[i]));
#endif SYSV2
#ifdef BSD4
                                putchar((char)string[i]);
#endif BSD4
#ifdef ULTRIX
                                putchar((char)string[i]);
#endif ULTRIX
                else {
#ifdef SYSV3
			err = write( socket, sp, 1 );
#endif SYSV3
#ifdef SYSV2
			err = write( socket, sp, 1 );
#endif SYSV2
#ifdef BSD4
			err = write( socket, sp, 1 );
#endif BSD4
#ifdef ULTRIX
			err = write( socket, sp, 1 );
#endif ULTRIX
			++sp;
		}
        }
        if(crlf)
        {

               if(socket==NULL)
               {
                                putchar(CR);
                                putchar(LF);
               }
               else
               {
			err = write( socket, "\r\n", 2 );
               }
        }
        if(socket==NULL)
                return(len);
        else
                return(NULL);
}
\End\Of\Shar\
else
  echo "will not over write ./transmit.c"
fi
chmod 400 ./transmit.c
if [ `wc -c ./transmit.c | awk '{printf $1}'` -ne 1330 ]
then
echo `wc -c ./transmit.c | awk '{print "Got " $1 ", Expected " 1330}'`
fi
if `test ! -s ./unlock.c`
then
echo "writing ./unlock.c"
cat > ./unlock.c << '\End\Of\Shar\'
/* @(#)unlock.c	1.2 */
#include "slugnet.h" 

unlock( string )
char string[];
{
	char lstring[FLNMLN+FLNMLN];
	strcpy(lstring,"LCK_");
	strcat(lstring,string);
	unlink( lstring );
}
\End\Of\Shar\
else
  echo "will not over write ./unlock.c"
fi
chmod 400 ./unlock.c
if [ `wc -c ./unlock.c | awk '{printf $1}'` -ne 182 ]
then
echo `wc -c ./unlock.c | awk '{print "Got " $1 ", Expected " 182}'`
fi
if `test ! -s ./verify.c`
then
echo "writing ./verify.c"
cat > ./verify.c << '\End\Of\Shar\'
/* @(#)verify.c	1.3 */
#include "net.h"

int verify( un, host )

/* attempts to use finger service to verify a un at a host */

char *un, *host;
{
#ifdef LOCAL
	return( 0 );
}
#endif LOCAL
#ifdef NETWORK
	char buffer[ 64 ];
	int i, j, portnum, socket;
	struct servent *finger;

	/* get the port of the finger service */

	/* finger = getservbyname( "finger", (char *)NULL ); */

	/* portnum = ( int )ntohl( finger->s_port ); */

	portnum = 79;

        /* try to connect to the socket */

	if(!( socket = callbyhost(host,portnum)))
		if(!( socket = callbyaddr(host,portnum)))
			return( 0 );

	/* write the request */

	strcpy( buffer, "@" );
	strcat( buffer, host );
	strcat( buffer, "\n" );
	
	i = strlen( buffer );
	if( write( socket, buffer, i ) != i )
		return( 0 );

	/* read until return is encountered, then try to compare */

	j = strlen( un );
	for(;;) {
		
		/* look for returns */

		i = read( socket, buffer, 1 );
		if( i != 1 ){
			close( socket );
			return( 0 );
		} else {
			if( buffer[ 0 ] == '\n' ){
			
				/* try to read a un's length */

				i = read( socket, buffer, j );
				if( i != j ){
					close( socket );
					return( 0 );
				}
				if(strncmp( un, buffer, j ) == NULL ){
					close( socket );
					return( 1 );
				}
			}
		}
	}
}
#endif NETWORK
\End\Of\Shar\
else
  echo "will not over write ./verify.c"
fi
chmod 400 ./verify.c
if [ `wc -c ./verify.c | awk '{printf $1}'` -ne 1278 ]
then
echo `wc -c ./verify.c | awk '{print "Got " $1 ", Expected " 1278}'`
fi
echo "Finished archive 1 of 6"
exit