home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / x / volume4 / xf / part02 / dir.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-09-07  |  3.4 KB  |  121 lines

  1. /*
  2.  * dir.h --
  3.  *
  4.  *    Declarations of procedures and structures that directly
  5.  *    apply to the DirTree.
  6.  *
  7.  * Copyright 1989 Regents of the University of California
  8.  * Permission to use, copy, modify, and distribute this
  9.  * software and its documentation for any purpose and without
  10.  * fee is hereby granted, provided that the above copyright
  11.  * notice appear in all copies.  The University of California
  12.  * makes no representations about the suitability of this
  13.  * software for any purpose.  It is provided "as is" without
  14.  * express or implied warranty.
  15.  *
  16.  * Author: Gary Shea (garys@earth.cchem.berkeley.edu)
  17.  *
  18.  * $Header: dir.h,v 1.3 89/07/18 00:05:41 garys Exp $
  19.  */
  20.  
  21. #ifndef _dir_h
  22. #define _dir_h
  23.  
  24. /* Two kinds of paths, relative and absolute. */
  25.  
  26. typedef enum {
  27.     RelPath, AbsPath, NoPath
  28. } PathKind ;
  29.  
  30. /* The dirTree struct is used to build a literal
  31. *  directory tree of selected files.  This may not
  32. *  be all that efficient, but it makes error checking
  33. *  and traversal easy.  The individual list element
  34. *  contains window information for its directory.
  35. */
  36.  
  37. # define FILE_SLOT_INCREMENT    20
  38. # define BRANCH_SLOT_INCREMENT    5
  39.  
  40. typedef u_short            StatMode ;
  41. typedef struct _dirTree        DirTree ;
  42. typedef struct _fileData    FileData ;
  43. typedef struct _branchData    BranchData ;
  44.  
  45. struct _fileData
  46. {
  47.     char    *file ;
  48.     StatMode    statMode ;
  49. } ;
  50.  
  51. struct _branchData
  52. {
  53.     DirTree    *branchPtr ;
  54.     int        index ;
  55. } ;
  56.  
  57. struct _dirTree
  58. {
  59.     char    *name ;        /* Name of this component of the path. */
  60.     char    *fullName ;    /* Full path name. */
  61.     char    *relName ;    /* Relative path name, if any. */
  62.     int        dirLevel ;    /* 0 for root, increasing towards leaves. */
  63.     int        normal ;    /* Picked => wanted when TRUE. */
  64.  
  65.     int        fileCnt ;    /* Number of files in the file list. */
  66.     int        fileSlots ;    /* Number of slots allocated. */
  67.     FileData    *files ;    /* File info for this directory. */
  68.  
  69.     Widget    shellW ;    /* Widget info. */
  70.     Widget    frameW ;
  71.     Widget    labelW ;
  72.     Widget    msgW ;
  73.     Widget    setW ;
  74.     Widget    upComW ;
  75.     Widget    quitComW ;
  76.     Widget    doneComW ;
  77.     Widget    fileComW ;
  78.     int        isDisplayed ;    /* To prevent multiple displays. */
  79.  
  80.     XtSetDataStruct    **setPtr ;    /* The set data in the set widget. */
  81.  
  82.     DirTree    *rootPtr ;    /* Pointer to node up the tree. */
  83.  
  84.     int        branchCnt ;    /* Number of sub-dir's. */
  85.     int        branchSlots ;    /* Slots for sub-dir's. */
  86.     BranchData    *branches ;
  87. } ;
  88.  
  89. typedef enum {
  90.     PreOrder, PostOrder
  91. } TreeOrder ;
  92.  
  93. typedef enum {
  94.     SetW, UpW, QuitW, DoneW
  95. } WidgetToFind ;
  96.  
  97. /* procedures */
  98.  
  99. char        **DecomposePath( char *path, PathKind *kind, int *parts ) ;
  100. DirTree        *DirTree_AddBranch( DirTree *trvPtr, int index ) ;
  101. DirTree     *DirTree_Alloc( void ) ;
  102. void        DirTree_CWD( void ) ;
  103. void        DirTree_ClientDump( DirTree *dirTreePtr, void *clientData ) ;
  104. void        DirTree_Dump( DirTree *dirTreePtr ) ;
  105. DirTree        *DirTree_Find( char *path ) ;
  106. DirTree        *DirTree_FindWidget( DirTree *dirTreePtr,
  107.             WidgetToFind kind, Widget w ) ;
  108. DirTree        *DirTree_GrowFiles( DirTree *dtPtr, int inc ) ;
  109. DirTree        *DirTree_GrowBranch( DirTree *dtPtr, int inc ) ;
  110. void        DirTree_Init( DirTree *dp ) ;
  111. DirTree     *DirTree_PresetNew( char *name,
  112.             char *fullName, int normal, int dirLevel ) ;
  113. void        DirTree_TreeDump( DirTree *rootPtr ) ;
  114. void        DirTree_TreeTrav( DirTree *dirTreePtr, TreeOrder travOrder,
  115.             void NodeOp( DirTree *nodePtr, void *clientData ),
  116.             void *clientData ) ;
  117. int        FillFilesList ( DirTree *trvPtr ) ;
  118.  
  119. #endif /* _dir_h */
  120.  
  121.