|
|
DataMuseum.dkPresents historical artifacts from the history of: Rational R1000/400 Tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about Rational R1000/400 Tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - downloadIndex: P T
Length: 2234 (0x8ba)
Types: TextFile
Names: »PIPE_C«
└─⟦149519bd4⟧ Bits:30000546 8mm tape, Rational 1000, !projects 93-07-13
└─⟦124ff5788⟧ »DATA«
└─⟦this⟧
└─⟦a7d1ea751⟧ Bits:30000550 8mm tape, Rational 1000, !users!projects 94_04_11
└─⟦129cab021⟧ »DATA«
└─⟦this⟧
└─⟦f64eaa120⟧ Bits:30000752 8mm tape, Rational 1000, !projects 93 02 16
└─⟦6f12a12be⟧ »DATA«
└─⟦this⟧
└─⟦2f6cfab89⟧ Bits:30000547 8mm tape, Rational 1000, !projects 94-01-04
└─⟦d65440be7⟧ »DATA«
└─⟦this⟧
#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);
}