home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Interactive Guide / c-cplusplus-interactive-guide.iso / c_ref / csource4 / 235_01 / ov.h < prev    next >
Encoding:
C/C++ Source or Header  |  1987-06-18  |  9.5 KB  |  250 lines

  1. /*  040  14-Feb-87  ov.h
  2.  
  3.         Copyright (c) 1987 by Blue Sky Software.  All rights reserved.
  4. */
  5.  
  6. #ifndef TRUE
  7. #define TRUE (1)
  8. #define FALSE (0)
  9. #endif
  10.  
  11. #ifndef NULL
  12. #define NULL (0)
  13. #endif
  14.  
  15. #define SCREEN_COLS (80)
  16. #define SCREEN_ROWS (25)
  17.  
  18. /* file name display constants */
  19.  
  20. #define VOL_ROW (1)
  21. #define FILE_STAT_ROW (VOL_ROW+2)
  22. #define TAG_STAT_ROW (FILE_STAT_ROW+1)
  23. #define MASK_ROW (VOL_ROW+2)
  24. #define UP_BOUND (TAG_STAT_ROW+1)
  25. #define FIRST_NROW (UP_BOUND+1)
  26. #define NAME_ROWS (STATUS_ROW-FIRST_NROW)
  27. #define STATUS_ROW (MENU_ROW - 1)
  28. #define MENU_ROW (PROMPT_ROW - 1)
  29. #define PROMPT_ROW (SCREEN_ROWS - 1)
  30.  
  31. #define PATH_COL (13)
  32. #define VOL_STAT_COL (2)
  33. #define NUM_FILES_COL (31)
  34. #define SPACE_USED_COL (44)
  35. #define MASK_COL (69)
  36.  
  37. /* view display constants */
  38.  
  39. #define FIRST_VROW (1)
  40. #define VIEW_ROWS (STATUS_ROW-FIRST_VROW)
  41.  
  42. /* help display constants */
  43.  
  44. #define FIRST_HROW (1)
  45. #define HELP_ROWS (STATUS_ROW-FIRST_VROW)
  46.  
  47. /* configuration parameters */
  48.  
  49. #define MAX_REPLY (SCREEN_COLS-4)      /* max user reply length to prompt */
  50. #define MAX_DIR 256                    /* max # dir's processed */
  51. #define MAX_FILES 1000                 /* max # files processed in files[] */
  52. #define MAX_PATHLEN 65                 /* max dir pathname length */
  53. #define MAX_VOLLEN 11                  /* max volume label length */
  54. #define MAX_NAMELEN 12                 /* max length of file name */
  55. #define MASK_LEN 10                    /* max len of file selection mask */
  56. #define MAX_DRIVES 20                  /* max drives we will handle */
  57.  
  58. /* display attribute for file names */
  59.  
  60. #define DIS_NORM 0             /* normal display */
  61. #define DIS_HIGH 1             /* highlighted display (current file) */
  62. #define DIS_BOX  2             /* dialog box display */
  63. #define DIS_HIBOX 3            /* highlight in dialog box */
  64. #define DIS_HEAD 4             /* header text */
  65. #define DIS_TEXT 5             /* static text display */
  66. #define DIS_TAGD 6             /* tagged display */
  67.  
  68. /* keyboard mapping */
  69.  
  70. #define LEFT 128               /* left arrow */
  71. #define RIGHT 129              /* right arrow */
  72. #define UP 130                 /* up arrow */
  73. #define DOWN 131               /* down arrow */
  74. #define PGUP 132               /* page up */
  75. #define PGDN 133               /* page dn */
  76. #define HOME 134               /* home */
  77. #define END 135                /* end */
  78. #define TAG 136                /* tag the current file toggle */
  79. #define HELP 137               /* Help via function key */
  80. #define OPENW 138              /* open file display window */
  81. #define CLOSEW 139             /* close file display window */
  82. #define NEXTW 140              /* goto next file display window */
  83. #define PREVW 141              /* goto prev file display window */
  84. #define INS 142                /* insert toggle key */
  85. #define DEL 143                /* delete char key */
  86. #define GOPAR 144              /* goto parent directory */
  87. #define GOSUB 145              /* goto subdirectory */
  88. #define NEXTT 146              /* goto next tagged file */
  89. #define PREVT 147              /* goto prev taggd file */
  90. #define RUBOUT 8               /* rubout last char key */
  91. #define RETURN 13              /* return key */
  92. #define EOF_CH (0x1A)          /* eof character which will quit overview */
  93. #define ESC_KEY (0x1b)         /* escape char */
  94.  
  95. /* file attribute flags */
  96.  
  97. #define TAGGED  (128)          /* file has been tagged */
  98. #define ARCHIVE (32)           /* file modified since backup */
  99. #define DIR     (16)           /* file is a subdirectory */
  100. #define SYSTEM  (4)            /* system file */
  101. #define HIDDEN  (2)            /* hidden file */
  102. #define RDONLY  (1)            /* file is read only */
  103.  
  104. /* Window update flags */
  105.  
  106. #define W_PACK (1)             /* pack the files before redisplay */
  107. #define W_DISP (2)             /* just redisplay */
  108.  
  109.  
  110. /* internal drive entry structure */
  111.  
  112. typedef struct drive_ent {
  113.    struct drive_ent *next;             /* pointer to next DRIVE_ENT in list */
  114.    int drive;                          /* drive letter, 'A' - ? */
  115.    unsigned int clustersiz;            /* size of a cluster on volume */
  116.    unsigned long vol_size;             /* size of volume */
  117.    unsigned long vol_free;             /* free space on volume */
  118.    char volbuf[MAX_VOLLEN+1];          /* current volume name buffer */
  119. } DRIVE_ENT;
  120.  
  121. /* internal file entry structure */
  122.  
  123. typedef struct file_ent {
  124.    char name[MAX_NAMELEN+1];           /* the file name */
  125.    unsigned char flags;                /* flags for this file */
  126.    unsigned index;                     /* sequential index number */
  127.    unsigned date;                      /* date last modified */
  128.    unsigned time;                      /* time last modified */
  129.    char *dirp;                         /* ptr to dir name for file if showall */
  130.    long size;                          /* file size in bytes or blocks */
  131. } FILE_ENT;
  132.  
  133. /* window structure */
  134.  
  135. typedef struct window {
  136.    struct window *next;                /* ptr to next winwow in list */
  137.    struct window *prev;                /* ptr to prev window in list */
  138.  
  139.    int curidx;                         /* current files[] index */
  140.  
  141.    int fwrow;                          /* first window display row */
  142.    int wrows;                          /* # window display rows */
  143.    int fnrow;                          /* first name display row */
  144.    int ndrows;                         /* # name display rows */
  145.  
  146.    int maxlen;                         /* size of the largest file name */
  147.    int colsiz;                         /* size of a name column in chars */
  148.  
  149.    int ncols;                          /* number of logical columns on screen */
  150.    int nrows;                          /* number of logical rows used 4 files */
  151.    int nbase;                          /* files[] idx of first name displayed */
  152.    int nfiles;                         /* number entries in files[] */
  153.  
  154.    int updated;                        /* NZ if window needs redisplay */
  155.  
  156.    DRIVE_ENT *drivep;                  /* pointer to DRIVE_ENT for window */
  157.  
  158.    unsigned int num_files;             /* number files selected in directory */
  159.    unsigned int num_tagged;            /* number of files tagged */
  160.    unsigned long tag_size;             /* size of tagged files */
  161.    unsigned long files_size;           /* # bytes used by files */
  162.  
  163.    char far *save_files;               /* ptr to files[] data for window */
  164.  
  165.    int sortopt;                        /* window sort option */
  166.    int (*sortfunc)();                  /* pointer to sorting function */
  167.  
  168.    unsigned char info_display;         /* NZ when exteneded file info shown */
  169.    unsigned char showall;              /* NZ when showall mode active */
  170.  
  171.    unsigned char selatrs;              /* selection attribute flags */
  172.    unsigned char maskcmp;              /* include/exclude meaning of mask */
  173.    char mask[MASK_LEN+1];              /* current file selection mask */
  174.  
  175.    char dirbuf[MAX_PATHLEN+1];         /* current dir name buffer */
  176. } WINDOW;
  177.  
  178. /* menu selection entry structure */
  179.  
  180. typedef struct menu_selection {
  181.    char *choice;
  182.    char *prompt;
  183.    int (*func)();
  184.    struct menu_selection *sub_menu;
  185. } MENU;
  186.  
  187. /* menu state control block */
  188.  
  189. #define MAX_MENU_SELECTIONS 20
  190.  
  191. typedef struct {
  192.    MENU *current_menu;
  193.    int number_selections;
  194.    int current_selection;
  195.    struct {
  196.       unsigned char position;
  197.       unsigned char length;
  198.    } selection[MAX_MENU_SELECTIONS];
  199. } MENU_STATE;
  200.  
  201. /* misc macros to translate coordinates */
  202.  
  203. #define min(a,b) ((a < b) ? a : b)             /* min of two values */
  204. #define yes(c) (c == 'Y' || c == 'y')          /* is char == Yy? */
  205.  
  206. #define lr2sr(r) (cw.fnrow + (r - cw.nbase))   /* logical row to screen row */
  207. #define lc2sc(c) (c * cw.colsiz)               /* logical col to screen col */
  208. #define idx2lr(i) (i % cw.nrows)               /* idx to logical row */
  209. #define idx2lc(i) (i / cw.nrows)               /* idx to logical col */
  210. #define idx2sr(i) (lr2sr(idx2lr(i)))           /* idx to screen row */
  211. #define idx2sc(i) (lc2sc(idx2lc(i)))           /* idx to screen col */
  212.  
  213. /* function declaration stuff */
  214.  
  215. #define ALTCALL pascal         /* alternate calling method reduces overhead */
  216.  
  217. int ALTCALL disp_file(FILE_ENT *, int);        /* common func declarations */
  218. int ALTCALL disp_vol_stats(void);
  219. int ALTCALL disp_file_stats(void);
  220. int ALTCALL setvattrib(int);
  221. int ALTCALL disp_str_at(char *, int, int);
  222. int ALTCALL disp_char_at(int, int, int);
  223. int ALTCALL disp_rep_at(int, int, int, int);
  224. int ALTCALL out_int(int, int, int);
  225. int ALTCALL out_long(long, int, int);
  226. int ALTCALL out_str(char *, int, int);
  227. int ALTCALL clr_eol(void);
  228. int ALTCALL adjust_window(void);
  229. int ALTCALL update_window(int);
  230. int ALTCALL on_screen(int);
  231. int ALTCALL fp_on(int);
  232. int ALTCALL fp_off(int);
  233. char * ALTCALL prompt(char *, char *, char *, int, int);
  234. char * ALTCALL read_str(int, char *, int);
  235. char * ALTCALL fname(FILE_ENT *);
  236.  
  237. #define Malloc(i) mustalloc(i)         /* for cases where we must alloc */
  238. #define Strdup(s) mustdup(s)           /* memory or we die */
  239. #define Strndup(s,n) mustndup(s,n)
  240.  
  241. char * ALTCALL mustalloc(int);         /* Malloc() */
  242. char * ALTCALL mustdup(char *);        /* Strdup() */
  243. char * ALTCALL mustndup(char *, int);  /* Strndup() */
  244.  
  245. #ifdef LINT_ARGS       /* include common function declarations if wanted */
  246. #include <io.h>
  247. #include <malloc.h>
  248. #include <string.h>
  249. #endif
  250.