00001 /************************************************************************* 00002 ** C version of CIO 00003 ** Copyright (c) 1991 Jim Patchell 00004 ** 00005 ** This is the Central Input Output device handler. This is probably 00006 ** a lame attempt to make access to various I/O devices a little more 00007 ** orthagonal. Maybe, maybe not. 00008 ** 00009 ** The interface function, cio only requires one parameter, but accepts 00010 ** a variable number of parameters depending on the type of function 00011 ** it is that is being executed. 00012 ** 00013 ** The functions that can be executed are: 00014 ** 00015 ** add handler 00016 ** open 00017 ** close 00018 ** get 00019 ** get record (read) 00020 ** put 00021 ** put record (write) 00022 ** status 00023 ** special command (xio) 00024 ** 00025 ** 00026 **************************************************************************/ 00027 00028 #include <stdio.h> 00029 #include <stdlib.h> 00030 #include <string.h> 00031 #include "fcntl.h" 00032 #include "cio.h" 00033 #include "task.h" 00034 00035 int CioPutC(IOCB *I,int c) 00036 { 00037 /* 00038 ** Put data to device 00039 ** : cio(PUTC,handle,data) 00040 */ 00041 if((I->mode & FCNTL_WRONLY) == 0) 00042 return(CIO_RDONLY); /* read only error */ 00043 // 00044 //look up function 00045 // 00046 return( (*htabs[I->ichid].HtabsEntry->putv)(I,c)); 00047 } 00048 00049 int CioWrite(IOCB *I,char *b,int n) 00050 { 00051 /* 00052 ** Write buffer to a device 00053 ** called as: cio(WRITE,handle,buffer,count); 00054 ** returns either an error or actual number of bytes written 00055 */ 00056 if((I->mode & FCNTL_WRONLY) == 0) 00057 return(CIO_RDONLY); /* read only error */ 00058 return( (*htabs[I->ichid].HtabsEntry->writev)(I,b,n)); 00059 }