home *** CD-ROM | disk | FTP | other *** search
- /******************************************
- * COPENBUF.C *
- * Copyright InfoTeSys 90. *
- ******************************************/
-
- #include <ts.h>
- #include <stdio.h>
- char *malloc();
-
- /***
- * COPENBUF( CHAR *CNAME , CHAN *cn, INT CSIZ ) - This function first checks to see
- * if channel CNAME already exists. If no channel CNAME exists, it allocates one
- * of CSIZ bytes and inserts it at the front of the list pointed by _CFRNT.
- * If one already exists, it simply increments the CNAME->openlev.
- * In both cases, a pointer to the CHAN structure is returned
- ***/
- CHAN *copenbuf( cname , cn, csiz )
- char *cname ;
- CHAN *cn ;
- int csiz ;
- {
-
- /** set CNAME **/
- critstart( DOS_CRCLASS ) ;
- cn->q.buf = (char *)cn + sizeof(CHAN);
- cn->nxt = _chfrnt ; /* insert channel in list */
- _chfrnt = cn ;
- strncpy( cn->cname , cname , CNSIZ ) ;
- cn->openlev = 1; /* first time its opened */
- cn->rf = cn->wf = NULL; /* okay to read and write */
- cn->q.bot = cn->q.top = cn->q.ahead = NULL ;
- cn->q.size = csiz - sizeof(CHAN);
- cn->q.full = 0 ;
- cn->q.empty = 1 ;
-
- critend( DOS_CRCLASS ) ;
- return cn ;
- }
-