Imported Robodoc.
[robodoc.git] / Source / directory.h
1 #ifndef ROBODOC_DIRECTORY_H
2 #define ROBODOC_DIRECTORY_H
3 /*
4 Copyright (C) 1994-2007  Frans Slothouber, Jacco van Weert, Petteri Kettunen,
5 Bernd Koesling, Thomas Aglassinger, Anthon Pang, Stefan Kost, David Druffner,
6 Sasha Vasko, Kai Hofmann, Thierry Pierron, Friedrich Haase, and Gergely Budai.
7
8 This file is part of ROBODoc
9
10 ROBODoc is free software; you can redistribute it and/or modify
11 it under the terms of the GNU General Public License as published by
12 the Free Software Foundation; either version 3 of the License, or
13 (at your option) any later version.
14
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 GNU General Public License for more details.
19
20 You should have received a copy of the GNU General Public License
21 along with this program.  If not, see <http://www.gnu.org/licenses/>.
22
23 */
24
25
26 #include "file.h"
27
28 /****s* Directory/RB_Directory
29  * NAME
30  *   RB_Directory -- the directory tree with the source files.
31  * FUNCTION
32  *   Stores information about files in a directory tree.
33  *   The whole structure consist of two linked lists.  One for
34  *   directory paths, and one for filenames.
35  * EXAMPLE
36  *   The following show an example structure.
37  *     RB_Directory             RB_Path
38  *     +-------+   +------+    +-------+   +-----------+
39  *     |       +-->| .    |--->| ./sub |-->| ./sub/sub |
40  *     |       |   +------+    +-------+   +-----------+
41  *     |       |      ^              ^            ^
42  *     |       |      |              |            |
43  *     |       |      |-----------+  +------+     +------+
44  *     |       |      |           |         |            |
45  *     |       |      |           |         |            |
46  *     |       |   +------+    +------+   +------+    +-------+
47  *     |       +-->|  a.c |--->| b.c  |-->| sa.c  |-->| ssb.c |
48  *     +-------+   +------+    +------+   +------+    +-------+
49  *                  RB_Filename
50  *
51  * ATTRIBUTES
52  *   * first    --  first RB_Filename in the list of files
53  *   * current  --  the last file that was returned in
54  *                  RB_Get_Next_Filename.
55  *   * last     --  the last RB_Filename in the list of files
56  *                   used for the insert operation
57  *   * first_path -- first RB_Path in the list of paths.
58  * SOURCE
59  */
60
61 struct RB_Directory
62 {
63     struct RB_Filename *first;  /* TODO should be called files */
64     struct RB_Filename *last;
65     struct RB_Path     *first_path;     /* TODO should be called paths */
66 };
67
68 /******/
69
70
71 /****t* Directory/T_RB_FileType
72  * FUNCTION
73  *   Constants for the two different filetypes that
74  *   ROBODoc recognizes.
75  * SOURCE
76  */
77
78 typedef enum
79 {
80     RB_FT_DIRECTORY = 1,
81     RB_FT_FILE = 2,
82     RB_FT_UNKNOWN = 3
83 } T_RB_FileType;
84
85 /******/
86
87
88 struct RB_Directory *RB_Get_RB_Directory(
89     char *arg_rootpath,
90     char *arg_docroot_name );
91 struct RB_Directory *RB_Get_RB_SingleFileDirectory(
92     char *arg_fullpath );
93 void                RB_Dump_RB_Directory(
94     struct RB_Directory *arg_rb_directory );
95 void                RB_Free_RB_Directory(
96     struct RB_Directory *arg_directory );
97 void                RB_Directory_Insert_RB_Path(
98     struct RB_Directory *arg_rb_directory,
99     struct RB_Path *arg_rb_path );
100 void                RB_Directory_Insert_RB_Filename(
101     struct RB_Directory *arg_rb_directory,
102     struct RB_Filename *arg_rb_filename );
103
104 void                RB_Fill_Directory(
105     struct RB_Directory *arg_rb_directory,
106     struct RB_Path *arg_path,
107     struct RB_Path *arg_doc_path );
108 int                 RB_Is_Source_File(
109     struct RB_Path *path,
110     char *filename );
111 int                 RB_To_Be_Skipped(
112     char *filename );
113 int                 RB_Not_Accepted(
114     char *filename );
115
116
117 char               *RB_Get_FileName(
118     char *arg_fullpath );
119 char               *RB_Get_PathName(
120     char *arg_fullpath );
121 void                RB_SortDirectory(
122     struct RB_Directory *arg_rb_directory );
123
124 int                 RB_Path_Compare(
125     void *p1,
126     void *p2 );
127 int                 RB_Filename_Compare(
128     void *p1,
129     void *p2 );
130 unsigned int        RB_Number_Of_Filenames(
131     struct RB_Directory *arg_rb_directory );
132 unsigned int        RB_Number_Of_Paths(
133     struct RB_Directory *arg_rb_directory );
134
135 #endif /* ROBODOC_DIRECTORY_H */