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;
-
- #ifdef CTDEBUG
- #define ALIMIT 30
- LOCAL struct {
- TEXT *aadr;
- UCOUNT aamt;
- } a[ALIMIT];
- LOCAL COUNT acnt,anul;
- LOCAL UCOUNT atot,amax,alev;
- #endif
-
- #define MEMLIM 55000
- LOCAL TEXT alcmem[MEMLIM];
- LOCAL UCOUNT ptrmem = 0;
-
- TEXT *salloc(numobj,sizobj)
- unsigned int numobj,sizobj;
- {
- sizobj *= numobj;
- numobj = ptrmem;
- ptrmem += sizobj;
- if (ptrmem > MEMLIM || ptrmem < numobj) {
- display(
- "\n\rMemory Allocation Error: Used / Addt'l Rqst / Limit ");
- numdis(numobj); numdis(sizobj); numdis(MEMLIM);
- return(NULL);
- }
- ptrmem = (ptrmem + 1) / 2 * 2;
- return(alcmem + numobj);
- }
-
- TEXT *mballc(numobj,sizobj)
- unsigned int numobj,sizobj;
- {
- TEXT *salloc();
-
- if (numobj == 0 || sizobj == 0) {
- sizobj = 1; /* to avoid false NULL return */
- numobj = 1;
- }
-
- #ifdef CTDEBUG
- if (acnt >= ALIMIT) {
- display("\n\rError ALIMIT. atot=");
- numdis(atot);
- killvap();
- }
-
- atot += a[acnt].aamt = numobj * sizobj;
- alev += a[acnt].aamt;
- if (alev > amax)
- amax = alev;
- return(a[acnt++].aadr = salloc(numobj,sizobj));
- #else
- return(salloc(numobj,sizobj));
- #endif
- }
-
- /* ------------------------------------------------------------ */
-
- 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 ctclb2.nov */
-