home *** CD-ROM | disk | FTP | other *** search
- /*
- * c-tree Low Level Library Interface
- * Novell Small Model VAP Support
- *
- * This program is the CONFIDENTIAL and PROPRIETARY property
- * of FairCom(R) Corporation. Any unauthorized use, reproduction or
- * transfer of this program is strictly prohibited.
- *
- * Copyright (c) 1985, 1986, 1987, 1988, 1989 FairCom Corporation
- * (Subject to limited distribution and
- * restricted disclosure only.)
- * *** ALL RIGHTS RESERVED ***
- *
- * 4006 West Broadway
- * Columbia, MO 65203
- *
- *
- * c-tree(R) Version 4.3
- * Release C
- * February 7, 1989 17:30
- *
- */
-
- #include "ctstdr.h" /* standard i/o header */
- #include "ctoptn.h" /* c-tree configuration options */
- #include "cterrc.h" /* c-tree error codes */
- #include "ctstrc.h" /* c-tree data structures */
-
- extern COUNT uerr_cod;
-
- #define CTDEBUG
- #ifdef CTDEBUG
- #define ALIMIT 30
- LOCAL struct {
- TEXT *aadr;
- UCOUNT aamt;
- } a[ALIMIT] = {0};
- LOCAL COUNT acnt = 0;
- LOCAL COUNT anul = 0;
- LOCAL UCOUNT atot = 0;
- LOCAL UCOUNT amax = 0;
- LOCAL UCOUNT alev = 0;
- #endif
-
- TEXT *lalloc(numobj,sizobj)
- unsigned int numobj,sizobj;
- {
- TEXT *valloc();
-
- sizobj = (sizobj * numobj + 15) / 16;
- return(valloc(sizobj));
- }
-
- TEXT *mballc(numobj,sizobj)
- unsigned int numobj,sizobj;
- {
- TEXT *lalloc(),*sp;
- FAST TEXT *tp;
-
- if (numobj == 0 || sizobj == 0) {
- sizobj = 1; /* to avoid false NULL return */
- numobj = 1;
- }
-
- #ifdef CTDEBUG
- if (acnt >= ALIMIT) {
- display("\n\rError ALIMIT. atot,acnt,ALIMIT ");
- numdis(atot);numdis(acnt);numdis(ALIMIT);
- display("\n\r");
- killvap();
- }
-
- atot += a[acnt].aamt = numobj * sizobj;
- alev += a[acnt].aamt;
- if (alev > amax)
- amax = alev;
- sp = tp = a[acnt++].aadr = lalloc(numobj,sizobj);
- #else
- sp = tp = lalloc(numobj,sizobj);
- #endif
- if (sp) {
- numobj *= sizobj;
- while (numobj--)
- *tp++ = '\0';
- }
- return(sp);
- }
-
- /* ------------------------------------------------------------ */
-
- VOID mbfree(objptr)
- TEXT *objptr;
- {
- FAST COUNT i;
-
- #ifdef CTDEBUG
- if (objptr != NULL) {
- /*free(objptr);*/
- for (i = acnt - 1; i >= 0; i--)
- if (objptr == a[i].aadr) {
- a[i].aadr = NULL;
- alev -= a[i].aamt;
- return;
- }
- display("\n\rError free. objptr=");
- numdis(objptr);
- } else
- anul++;
- #else
- if (objptr != NULL)
- free(objptr);
- #endif
- }
-
- #ifdef CTDEBUG
- VOID arep(mode)
- COUNT mode;
- {
- FAST COUNT i;
-
- display("\n\racnt / anul / atot / amax / alev: ");
- numdis(acnt); numdis(anul); numdis(atot); numdis(amax); numdis(alev);
- }
- #endif
-
- /* --------------------------------------------------------------------
- routine to copy tree buffer contents. it does not terminate on null
- byte.
- */
-
- #ifndef cpybuf
- VOID cpybuf(dp,sp,n)
- PFAST TEXT *dp,*sp;
- PFAST UCOUNT n;
-
- {
- while (n-- != 0)
- *dp++ = *sp++;
- }
- #endif
-
- COUNT uerr(err_no)
- COUNT err_no;
- {
- return(uerr_cod = err_no);
- }
-
- VOID terr(err_no)
- COUNT err_no;
- {
- display("\n\n\rc-tree fatal error #");
- numdis(err_no);
- display("\n\r");
- killvap();
- }
-
- #ifdef UNIFRMAT
-
- VOID revbyt(tp,wrdcnt)
- PFAST TEXT *tp;
- PFAST COUNT wrdcnt;
- {
- TEXT ch;
-
- while (wrdcnt-- > 0) {
- ch = *tp++;
- *(tp - 1) = *tp;
- *tp++ = ch;
- }
- }
-
- #endif
-
- VOID revobj(tp,len)
- PFAST TEXT *tp;
- COUNT len;
- {
- FAST TEXT *hp;
- TEXT ch;
-
- hp = tp + len - 1;
- while (tp < hp) {
- ch = *tp;
- *tp++ = *hp;
- *hp-- = ch;
- }
- }
-
- /* end of ctclb2c.nov */
-