home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c023 / 1.img / PROGRAMS / BTPARSE.C < prev    next >
Encoding:
C/C++ Source or Header  |  1987-11-05  |  1.9 KB  |  72 lines

  1. /* (C) Copyright 1984,85,86,87 Walter L. Peacock   All Rights Reserved   */
  2.  
  3. /* THIS PROGRAM BELONGS TO WALTER L. PEACOCK.  IT IS CONSIDERED A TRADE */
  4. /* SECRET AND IS NOT TO BE DIVULGED OR USED BY PARTIES WHO HAVE NOT   */
  5. /* RECEIVED WRITTEN AUTHORIZATION FROM THE OWNER.                  */
  6.  
  7. /* b t r p a r s e . c      last mod: 11/23/84   */
  8. /*  parse btree and print keys and record locations on the printer.      */
  9.  
  10. #include <stdio.h>
  11. #include "cbtree.h"
  12. /* btfio.h *must* be included when bt_open() is used */
  13. #include "btfio.h"
  14.  
  15. void main(argc, argv)
  16. int argc;
  17. char **argv;
  18. {
  19.    extern long getroot(), atol();
  20.    extern int   bt_ltoa();      /* custom cbtree routine: see ltoa.c */
  21.    extern char *strcpy(), *calloc();
  22.    extern void  free();
  23.    extern FILE *fopen();
  24.    long rootptr;
  25.    struct btcommo btindex;
  26.    FILE  *fprn;
  27.    int fdidx, pwidth;
  28.    char inpc[8];
  29.  
  30.    if( (fprn = fopen(PRINTER,"w") ) == NULL)    /* see cbtrdef.h */
  31.    {
  32.       puts("Can't fopen printer");
  33.       exit(ERR);
  34.    }
  35.    scr_clr();
  36.    scr_curs(5, 20);
  37.    printf("    Parsing  B-Tree... ");
  38.  
  39.          /*  M A I N  C O N T R O L  P R O G R A M */
  40.  
  41.    getbname(argc, argv, &btindex);
  42.  
  43.    if((fdidx = bt_open(btindex.idxname,O_RDWR)) == ERR)
  44.    {
  45.       printf("\nBTPARSE: can't open file '%s'", btindex.idxname);
  46.       printf("\nBTPARSE: re-run BTSETUP.EXE\n");
  47.       exit(0);
  48.    }
  49.  
  50.    printf("\nB+tree Name : %s ", btindex.btname);
  51.    printf("\nIndex File Name : %s ", btindex.idxname);
  52.  
  53.    repeat
  54.    {
  55.       printf("\n\nEnter the width of your paper ==>");
  56.       gets(inpc);
  57.       pwidth = atoi(inpc);
  58.    }
  59.    until( pwidth >= 40  &&  pwidth < 256 );
  60.  
  61.    rootptr = getroot(fdidx, btindex.findroot);   /* get ptr to idx root node */
  62.  
  63.    btprint(fdidx, fprn, rootptr, pwidth, &btindex, 0);
  64.  
  65.    close(fdidx);
  66.    btrterm(&btindex);
  67.    fprintf(fprn,"\n");
  68.    fclose(fprn);
  69.    printf("\n");
  70. }
  71.  
  72.