1: #ifndef lint
   2: static char *rcsid =
   3:    "$Header: fpipe.c,v 1.3 85/05/22 07:53:41 sklower Exp $";
   4: #endif
   5: 
   6: 
   7: /*					-[Sat Jan 29 12:44:16 1983 by jkf]-
   8:  * 	fpipe.c				$Locker:  $
   9:  * pipe creation
  10:  *
  11:  * (c) copyright 1982, Regents of the University of California
  12:  */
  13: 
  14: 
  15: #include "global.h"
  16: #include <signal.h>
  17: 
  18: FILE *fpipe(info)
  19: FILE *info[2];
  20: {
  21:     register FILE *p;
  22:     int fd[2];
  23: 
  24:     if(0 > pipe(fd)) return( (FILE *) -1);
  25: 
  26:     if(NULL==(p = fdopen(fd[0],"r"))) {
  27:         close(fd[0]);
  28:         close(fd[1]);
  29:         return( (FILE *) -1);
  30:     }
  31:     info[0] = p;
  32:     if(NULL==(p = fdopen(fd[1],"w"))) {
  33:         close(fd[0]);
  34:         close(fd[1]);
  35:         return( (FILE *) -1);
  36:     }
  37:     info[1] = p;
  38: 
  39:     return((FILE *) 2); /*indicate sucess*/
  40: }
  41: /* Nioreset *************************************************************/
  42: 
  43: lispval
  44: Nioreset() {
  45: #ifndef RTPORTS
  46:     register FILE *p;
  47: 
  48:     for(p = &_iob[3]; p < _iob + _NFILE; p++) {
  49:         if(p->_flag & (_IOWRT | _IOREAD)) fclose(p);
  50:         }
  51: #else   RTPORTS
  52:     lispval NiorUtil();
  53: 
  54:     _fwalk(NiorUtil);
  55: #endif	RTPORTS
  56:     return(nil);
  57: }
  58: 
  59: #ifdef RTPORTS
  60: FILE FILEdummy;
  61: 
  62: static lispval
  63: NiorUtil(p)
  64: FILE *p;
  65: {
  66:     lispval handy;
  67:     if(p==stdin||p==stdout||p==stderr)
  68:         return(0);
  69:     fclose(p);
  70:     handy = P(p);
  71:     if(TYPE(handy)==PORT) {
  72:         handy->p = &FILEdummy;
  73:     }
  74:     return(nil);
  75: }
  76: FILE **xports;
  77: 
  78: #define LOTS (LBPG/(sizeof (FILE *)))
  79: lispval P(p)
  80: FILE *p;
  81: {
  82:     register FILE **q;
  83:     extern int fakettsize;
  84: 
  85:     if(xports==((FILE **) 0)) {
  86:         /* this is gross.  I don't want to change csegment -- kls */
  87:         xports = (FILE **) csegment(OTHER,LOTS,0);
  88:         SETTYPE(xports,PORT,31);
  89:         for(q = xports; q < xports + LOTS; q++) {
  90:             *q = &FILEdummy;
  91:         }
  92:     }
  93:     for(q = xports; q < xports + LOTS; q++) {
  94:         if(*q==p) return ((lispval)q);
  95:         if(*q==&FILEdummy) {
  96:             *q = p;
  97:             return ((lispval)q);
  98:         }
  99:     }
 100:     /* Heavens above knows this could be disasterous in makevals() */
 101:     error("Ran out of Ports",FALSE);
 102: }
 103: 
 104: #endif	RTPORTS
 105: 
 106: FILE *
 107: fstopen(base,count,flag)
 108: char *base;
 109: char *flag;
 110: {
 111:     register FILE *p = fdopen(0,flag);
 112: 
 113:     p->_flag |= _IOSTRG;
 114:     p->_cnt = count;
 115:     p->_ptr = p->_base = base;
 116:     p->_file = -1;
 117:     return(p);
 118: }
 119: 
 120: #ifdef SPISFP
 121: char *
 122: alloca(howmuch)
 123: register int howmuch;
 124: {
 125:     howmuch += 3 ;
 126:     howmuch >>= 2;
 127:     xsp -= howmuch;
 128:     if (xsp < xstack) {
 129:         xsp += howmuch;
 130:         xserr();
 131:     }
 132:     return((char *) xsp);
 133: }
 134: #endif

Defined functions

NiorUtil defined in line 62; used 2 times
Nioreset defined in line 43; used 1 times
fpipe defined in line 18; used 3 times
fstopen defined in line 106; used 4 times

Defined variables

rcsid defined in line 2; never used

Defined macros

LOTS defined in line 78; used 3 times
Last modified: 1985-08-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1209
Valid CSS Valid XHTML 1.0 Strict