home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / drdobbs / c_spec / sources / dir.h < prev    next >
Text File  |  1986-02-20  |  3KB  |  80 lines

  1. /*
  2.  * DIR.H
  3.  *    #defines and typedefs needed to talk to the routine dir().
  4.  *    A pointer to the DIRECTORY structure is passed to dir().
  5.  *    DIRECTORY structures are created by mk_dir() and deleted with
  6.  *    del_dir().
  7.  *
  8.  *    On entry:
  9.  *        dirv     is the first of an uninitialized array of character
  10.  *                                 pointers.
  11.  *        lastdir     should be initialized to point at dirv.
  12.  *        maxdirs     is the size of the above
  13.  *        nfiles    
  14.  *        ndirs    
  15.  *        nbytes     is the total file count, the total directory count
  16.  *             and the total byte count. These will be incremented
  17.  *             as appropriate and are usually set to 0 before
  18.  *             calling dir().
  19.  *        width     should be initialized to 0 before calling dir().
  20.  *        vol_label is undefined on entry to dir().
  21.  *        longf     is 1 if entrys are to be printed in long format
  22.  *        files     is 1 if files are included in the list.
  23.  *        dirs     is 1 if directors are included in the list.
  24.  *        graphics is 1 if directories are highlighted with boldface.
  25.  *        hidden   is 1 if hidden files are to be included in the list.
  26.  *        path     is 1 if the path name is to be included in the list.
  27.  *        label     is 1 if you want to get the volume label
  28.  *        exp     is 1 if you want the contents of a subdirectory to
  29.  *             be listed rather than the directory name when. This
  30.  *             is only looked at if no wild cards are present in
  31.  *             the file spec.
  32.  *        sort    is 1 if you want the list sorted.
  33.  *
  34.  *    all other fields are ignored. On exit the structure will have been
  35.  *    updated as follows:
  36.  *
  37.  *        lastdir     will be incremented to point at the last entry added
  38.  *             to the dirv table.
  39.  *        maxdirs    will be decremented to reflect the added entries.
  40.  *        nfiles    is the number of added entries which are files.
  41.  *        ndirs    is the number of added entries which are directories.
  42.  *            Note that the equivalent of argc can be derrived by
  43.  *            adding ndirs and nfiles together.
  44.  *        nbytes    will have the total size in bytes of all files added
  45.  *            to dirv. This number is the number of bytes actually
  46.  *            occupied by the file, ie. the size returned by DOS
  47.  *            rounded up to the nearest multiple of the disk's
  48.  *            cluster size.
  49.  *        vol_label will hold the volume lable provided that "label" was
  50.  *            set on entry.
  51.  *        width    will hold the length of the widest entry added to dirv
  52.  *
  53.  *    all other fields will have the same values they had on entry.
  54.  */
  55.  
  56. typedef    struct 
  57. {
  58.     char     **lastdir ;    /* Most recent addition to dirv        */
  59.     int     maxdirs   ;    /* # of free slots in dirv        */
  60.     int     nfiles    ;    /* # of used slots that are files    */
  61.     int     ndirs       ;    /* # of used slots that are directories    */
  62.     long     nbytes       ;    /* byte count of files            */
  63.     char     vol_label[12]; /* volume lable if requested        */
  64.     unsigned width      : 7 ; /* Width of widest element in dirv    */
  65.  
  66.                 /* Various flags control how dir works: */
  67.     unsigned longf    : 1 ;    /* Use long format for entries        */
  68.     unsigned files    : 1 ;    /* Include files in list        */
  69.     unsigned dirs     : 1 ; /* Include directories in list        */
  70.     unsigned graphics : 1 ;    /* Use graphics around directory names    */
  71.     unsigned hidden      : 1 ;    /* List hidden files            */
  72.     unsigned path      : 1 ;    /* List complete path if given        */
  73.     unsigned label      : 1 ;    /* Load vol_label with volume label    */
  74.     unsigned exp      : 1 ;    /* Expand sub-directories        */
  75.     unsigned sort      : 1 ; /* Sort added entries            */
  76.  
  77.     char     *dirv[1];    /* The first of the dirv entries    */
  78. }
  79. DIRECTORY;
  80.