home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 13 / 13.iso / s / s001 / 1.ddi / TS / SRC / COPENBUF.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-01-17  |  1.2 KB  |  39 lines

  1.                  /******************************************
  2.            *            COPENBUF.C             *
  3.            * Copyright InfoTeSys         90. *
  4.                ******************************************/
  5.  
  6. #include <ts.h>
  7. #include <stdio.h>
  8. char    *malloc();
  9.  
  10. /***
  11. * COPENBUF( CHAR *CNAME , CHAN *cn, INT CSIZ ) - This function first checks to see
  12. * if channel CNAME already exists. If no channel CNAME exists, it allocates one
  13. * of CSIZ bytes and inserts it at the front of the list pointed by _CFRNT. 
  14. * If one already exists, it simply increments the CNAME->openlev.
  15. * In both cases, a pointer to the CHAN structure is returned 
  16. ***/
  17. CHAN    *copenbuf( cname , cn, csiz )
  18. char    *cname ;            
  19. CHAN    *cn ;
  20. int    csiz ;
  21. {
  22.  
  23.     /** set CNAME **/
  24.     critstart( DOS_CRCLASS ) ;
  25.     cn->q.buf = (char *)cn + sizeof(CHAN);
  26.     cn->nxt   = _chfrnt ;     /* insert channel in list */
  27.     _chfrnt   = cn ;
  28.     strncpy( cn->cname , cname , CNSIZ ) ;
  29.     cn->openlev = 1;        /* first time its opened */
  30.     cn->rf = cn->wf = NULL; /* okay to read and write */
  31.     cn->q.bot = cn->q.top = cn->q.ahead = NULL ;
  32.     cn->q.size = csiz - sizeof(CHAN);
  33.     cn->q.full = 0 ;
  34.     cn->q.empty = 1 ;
  35.  
  36.     critend( DOS_CRCLASS ) ;
  37.     return cn ;
  38. }
  39.