DataMuseum.dk

Presents historical artifacts from the history of:

Rational R1000/400

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

See our Wiki for more about Rational R1000/400

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - download

⟦17e26f8cb⟧ TextFile

    Length: 2233 (0x8b9)
    Types: TextFile
    Notes: R1k Text-file segment

Derivation

└─⟦8527c1e9b⟧ Bits:30000544 8mm tape, Rational 1000, Arrival backup of disks in PAM's R1000
    └─ ⟦cfc2e13cd⟧ »Space Info Vol 2« 
        └─⟦ce226bb57⟧ 
            └─⟦this⟧ 

TextFile

#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <errno.h>
#include <fcntl.h>

#define ACIA_READ	"/tmp/AciaR"
#define ACIA_WRITE	"/tmp/AciaW"
#define MAX_ACIA	10

struct s_pipe {
  char NameRead[20];
  char NameWrite[20];
  int FdRead;
  int FdWrite;
} pipe[MAX_ACIA];

int Open(char *name,int mode)
{
int fd;

#ifdef DEBUG
printf("OpenPipe : %s  ",name);
if (mode == O_RDONLY)
	printf("in RDONLY\n");
else	printf("in WRONLY\n");
#endif
  fd=open(name,mode|O_SYNC,0);
  switch(fd) 
  {
    case -1 : if (errno != 2)
    		fprintf(stderr,"Open Error %d on Named Pipe %s \n",errno,name);
	      return 0;
    default : return fd;
  }
}

int OpenPipe(int Id)
{
char ReadName[20];
char WriteName[20];
int  fd[2];

  sprintf(ReadName,"%s%d",ACIA_READ,Id);
  if ((fd[0]=Open(ReadName,O_RDONLY|O_NDELAY)) == 0)
	return FALSE;
  sprintf(WriteName,"%s%d",ACIA_WRITE,Id);
  if ((fd[1]=Open(WriteName,O_WRONLY)) == 0)
 	return FALSE;
  pipe[Id].FdRead=fd[0];
  pipe[Id].FdWrite=fd[1]; 
  strcpy(pipe[Id].NameRead,ReadName);
  strcpy(pipe[Id].NameWrite,WriteName);
  return TRUE;
}

void PutPipe(int Id, char car)
{
int ret;

    ret=write(pipe[Id].FdWrite,&car,1);
    switch (ret)
    {
      case 0  : break; 
      case -1 : fprintf(stderr,"Write Error %d on Named Pipe %s \n",
		errno,pipe[Id].NameWrite);
                break;
      default : 
#ifdef DEBUG
printf("PutPipe : %d %s car : %c %x\n",Id,pipe[Id].NameWrite,car,car);
#endif
		break;
    }
}

int GetPipe(int Id)
{
char car;

  switch (read(pipe[Id].FdRead,&car,1))
  {
     case 0  : return 1000;
     case -1 : fprintf(stderr,"Read Error %d on Named Pipe %s \n",
			errno,pipe[Id].NameRead);
               return 2000;
     default : 
#ifdef DEBUG
printf("GetPipe : %d %s  car = %c %x\n",Id,pipe[Id].NameRead,car,car);
#endif
    	       return (int)car;
  }
}

void ClosePipe(int Id)
{
#ifdef DEBUG
printf("Close: %s \n",pipe[Id].NameRead);
#endif
    if (close(pipe[Id].FdRead))
    	fprintf(stderr,"Close Error %d on Named Pipe %s \n",
		errno,pipe[Id].NameRead);
#ifdef DEBUG
printf("Close: %s \n",pipe[Id].NameWrite);
#endif
    if (close(pipe[Id].FdWrite))
    	fprintf(stderr,"Close Error %d on Named Pipe %s \n",
		errno,pipe[Id].NameWrite);
}