home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / gnu / vh / vh.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-05-11  |  3.3 KB  |  98 lines

  1. /* vh.h --- interface to display-independent retrieval code */
  2.  
  3. #define PATHLEN        256    /* maximum filename size */
  4. #define    BTSMAX        100    /* backtrack stack size */
  5. #define    NOPLACE        (-1)    /* out-of-bounds for screen coordinate */
  6. #define NOWHERE        (-1L)    /* invalid file position */
  7. #define    LNSZ        256    /* maximum text line width */
  8. #define MAXWIDTH    256    /* maximum screen width */
  9. #define    ITEMSMAX    2400    /* max index items per document */
  10.  
  11. #ifndef UNIX
  12. typedef long daddr_t;
  13. #else
  14. #if !defined(AOS)
  15. #include <unistd.h>
  16. #endif /* !defined(AOS) */
  17. #include <sys/types.h>
  18. #endif /*  */
  19.  
  20. #ifndef SEEK_SET    /* AOS is bogus */
  21. #define SEEK_SET    0
  22. #define SEEK_END    2
  23. #endif
  24.  
  25. /* index of last line on screen available for text display */
  26. #ifdef POPUP
  27. #define LASTLINE    (LINES - 1)
  28. #else
  29. #define LASTLINE    (LINES - 2)
  30. #endif /* POPUP */
  31.  
  32. /* this structure appears at the beginning of each index */
  33. typedef struct
  34. {
  35.     long    magic;        /* magic number, distinguishes file type */
  36.     int        nfiles;        /* count of text files in the database */
  37.                 /* multi-files isn't implemented yet */
  38. }
  39. vhhdr;
  40.  
  41. /* this structure represents a select region */
  42. typedef struct
  43. {
  44.     int    xl, yl, xr, yr;
  45. }
  46. region;
  47.  
  48. /*
  49.  * FILEINFO -- everything we need to keep context of text and index
  50.  */
  51. typedef struct fileinfo
  52. {
  53.     FILE *fp;            /* file pointer */
  54.     daddr_t endpos;        /* end file pos (== file length) */
  55.     daddr_t toppos;        /* pos of new top line on screen */
  56.     daddr_t dsptoppos;        /* pos of current top line on screen */
  57.     daddr_t dspnextpos;        /* pos of line after last line on screen */
  58.     daddr_t lastpagetoppos;    /* pos of top line of last page */
  59.     daddr_t hitpos;        /* pos where string search hit */
  60.     region sel;            /* selected region on screen (if any) */
  61.     int ythumb;            /* current thumb row */
  62.     int btscnt;            /* backtrack stack current count */
  63.     daddr_t bts[BTSMAX];    /* backtrack stack of file positions */
  64.     region selbts[BTSMAX];    /* backtrack stack of link selections */
  65. }
  66. FILEINFO;
  67.  
  68. /* this function must be defined for vh.c to compile */
  69. extern void gettext();        /* fetch text from terminal screen */
  70.  
  71. /* entry points of vh.c */
  72. extern void chkindex();        /* check for pathologies in file */
  73. extern void mkindex();        /* generate index for file */
  74. extern char *headword();    /* is given line a headword? */
  75. extern bool initbrowse();    /* initialize browse */
  76. extern void setlastpage();    /* set lastpagetoppos members */
  77. extern daddr_t iflink();    /* test for presence of link */
  78. extern daddr_t getnextln();    /* get next line */
  79. extern daddr_t getprevln();    /* get previous line */
  80. extern daddr_t xlocate();    /* go to term by name */
  81. extern daddr_t ilocate();    /* incremental-locate term */
  82. extern daddr_t ffind();        /* find string in file */
  83. extern daddr_t ifind();        /* incremental-find string in file */
  84. extern daddr_t jrandom();    /* return offset of random entry */
  85. extern region findnextsel();    /* find next possible selection */
  86. extern region findprevsel();    /* find previous possible selection */
  87. extern void enqueue();        /* stack a location */
  88. extern void dequeue();        /* unstack a location */
  89. extern FILEINFO vhi;        /* file info for index */
  90. extern FILEINFO *vht;        /* file info for text */
  91.  
  92. #if defined(__TURBOC__) && defined(FFGETS)
  93. extern char *ffgets();        /* faster fgets */
  94. #define fgets(s,n,f) ffgets((s), (n), (f))
  95. #endif /* defined(__TURBOC__) && defined(FFGETS) */
  96.  
  97. /* vh.h ends here */
  98.