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 u

⟦72d1719eb⟧ TextFile

    Length: 2757 (0xac5)
    Types: TextFile
    Names: »unbind.c«

Derivation

└─⟦3d0c2be1b⟧ Bits:30001254 ISODE-5.0 Tape
    └─⟦eba4602b1⟧ »./isode-5.0.tar.Z« 
        └─⟦d3ac74d73⟧ 
            └─⟦this⟧ »isode-5.0/others/quipu/uips/dish/unbind.c« 

TextFile

/* unbind.c - dish shell unbind and squid commands */

#ifndef	lint
static char *rcsid = "$Header: /f/osi/others/quipu/uips/dish/RCS/unbind.c,v 6.0 89/03/18 23:34:32 mrose Rel $";
#endif

/* 
 * $Header: /f/osi/others/quipu/uips/dish/RCS/unbind.c,v 6.0 89/03/18 23:34:32 mrose Rel $
 *
 *
 * $Log:	unbind.c,v $
 * Revision 6.0  89/03/18  23:34:32  mrose
 * Release 5.0
 * 
 */

/*
 *				  NOTICE
 *
 *    Acquisition, use, and distribution of this module and related
 *    materials are subject to the restrictions of a license agreement.
 *    Consult the Preface in the User's Manual for the full terms of
 *    this agreement.
 *
 */


#include <stdio.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "quipu/util.h"
#include <signal.h>

#ifndef BINDIR
#define BINDIR "/usr"
#endif

#define BIGBUF 100000
extern int errno;
char retfile [LINESIZE];
int fd;

main (argc,argv)
int argc;
char ** argv;
{
int res;
char buffer [BIGBUF];
char sendfile [LINESIZE];
int i;
char * ptr;
void pipe_quit ();
char * getenv(), *ttyname(), *sprintf();

	(void) umask(0);
	(void) sprintf (retfile,"/tmp/dish%d",getpid());
	(void) sprintf (sendfile,"/tmp/dish-%s-%d",rindex(ttyname(0),'/')+1, getuid());
	
	setbuf (stdout,NULLCP);
	setbuf (stderr,NULLCP);

	if (mknod (retfile,S_IFIFO|0660,0) == -1) {
		(void) fprintf (stderr,"Can't create result file %s\n",retfile);
		exit (-5);
	}
	
	for (i=1; i<=15; i++)
		(void) signal(i,pipe_quit);

	if ((fd = open (sendfile,O_WRONLY|O_NDELAY)) == -1) {
		(void) fprintf (stderr,"No connection and no cache !!!\n");
		(void) unlink (retfile);
		exit (0);
	}

	argc--;
	if ((ptr = rindex (argv[0],'/')) == NULLCP)
		(void) sprintf (buffer,"%s:%s",retfile,argv[0]);
	else
		(void) sprintf (buffer,"%s:%s",retfile,++ptr);
	*argv++;
	
	while (argc--) {
		(void) strcat (buffer," ");
		(void) strcat (buffer,*argv++);
	}
	
	if (( res =write (fd, buffer,strlen (buffer))) == -1) {
		(void) fprintf (stderr,"Write failed\n");
		(void) close (fd);
		(void) unlink (retfile);		
		exit (-2);
	}
	(void) close (fd);


	/* get results */
	if (( fd = open (retfile,O_RDONLY)) < 0) {
		(void) fprintf (stderr,"Can't read results\n");
		(void) unlink (retfile);
		exit (-3);
	}
	
	if (( res = read (fd,buffer,BIGBUF)) == -1) {
		(void) fprintf (stderr,"Read failed (%d)\n",errno);
		(void) unlink (retfile);		
		(void) close (fd);
		exit (-4);
	}

	*(buffer+res) = 0;

	if (*buffer == '2')
		fputs (&buffer[1], stderr);
	else if (*buffer == '1')
		fputs (&buffer[1], stdout);

	(void) close (fd);
	(void) unlink (retfile);

	if (*buffer == '2')
		exit (-1);
}

void pipe_quit (sig)
int     sig;
{
	extern char *sys_siglist[];
	
	(void) fprintf (stderr,"(%s) exiting...\n",sys_siglist[sig]);
	(void) unlink (retfile);
}