home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / qrymod / tree.c < prev    next >
Encoding:
C/C++ Source or Header  |  1985-01-23  |  942 b   |  56 lines

  1. # include    <ingres.h>
  2. # include    <tree.h>
  3. # include    <symbol.h>
  4. # include    "qrymod.h"
  5. # include    <sccs.h>
  6.  
  7. SCCSID(@(#)tree.c    8.1    12/31/84)
  8.  
  9. /*
  10. **  TREE -- create new tree node.
  11. **
  12. **    This is a stripped down version of the same thing in the
  13. **    parser.
  14. **
  15. **    It only knows about lengths of zero and two.
  16. **
  17. **    Parameters:
  18. **        lptr -- the left pointer.
  19. **        rptr -- the right pointer.
  20. **        typ -- the node type.
  21. **        len -- the node length.
  22. **        value -- the node value.
  23. **
  24. **    Returns:
  25. **        A pointer to the created node.
  26. **
  27. **    Side Effects:
  28. **        Space is taken from Qbuf.
  29. */
  30.  
  31.  
  32. QTREE *
  33. tree(lptr, rptr, typ, len, value)
  34. QTREE    *lptr;
  35. QTREE    *rptr;
  36. char    typ;
  37. int    len;
  38. int    value;
  39. {
  40.     register QTREE    *tptr;
  41.     extern char    *need();
  42.     register int    l;
  43.  
  44.     l = len;
  45.  
  46.     tptr = (QTREE *) need(Qbuf, l + QT_HDR_SIZ);
  47.     tptr->left = lptr;
  48.     tptr->right = rptr;
  49.     tptr->sym.type = typ;
  50.     tptr->sym.len = l;
  51.  
  52.     if (l > 0)
  53.         tptr->sym.value.sym_data.i2type = value;
  54.     return (tptr);
  55. }
  56.