Add GNU LGPL headers to all .c .C and .h files
[oweals/cde.git] / cde / lib / DtSvc / DtUtil2 / FileUtil.h
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
6  * These libraries and programs are free software; you can
7  * redistribute them and/or modify them under the terms of the GNU
8  * Lesser General Public License as published by the Free Software
9  * Foundation; either version 2 of the License, or (at your option)
10  * any later version.
11  *
12  * These libraries and programs are distributed in the hope that
13  * they will be useful, but WITHOUT ANY WARRANTY; without even the
14  * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15  * PURPOSE. See the GNU Lesser General Public License for more
16  * details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with these librararies and programs; if not, write
20  * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21  * Floor, Boston, MA 02110-1301 USA
22  */
23 /*
24  * File:         FileUtil.h $XConsortium: FileUtil.h /main/4 1995/10/26 15:21:50 rswiston $
25  * Language:     C
26  *
27  * (c) Copyright 1988, Hewlett-Packard Company, all rights reserved.
28  *
29  * (c) Copyright 1993, 1994 Hewlett-Packard Company                     *
30  * (c) Copyright 1993, 1994 International Business Machines Corp.       *
31  * (c) Copyright 1993, 1994 Sun Microsystems, Inc.                      *
32  * (c) Copyright 1993, 1994 Novell, Inc.                                *
33  */
34
35 #ifndef _FileUtil_h
36 #define _FileUtil_h
37
38 extern int _DtCreateDirs( char *path,
39                          int mode) ;
40
41 /******************
42  *
43  * Function Name:  _DtCreateDirs
44  *
45  * Description:
46  *
47  *      This function is passed a directory path to create and the mode
48  *      for the directory.  It will create any of the parent directories 
49  *      on the path that do not already exist.
50  *
51  *      This function may fail if any of the directories on the path already
52  *      exist and are not writable.  If some component of the path already
53  *      exists and is not a directory, a failure will be returned.  
54  *
55  *      If some component of the path exists as a directory but does not have 
56  *      the specified mode, this will NOT cause a failure to be returned.
57  *      This implies that if this function is called to create a writeable
58  *      directory, it is possible for the function to return successfully
59  *      but the directory may not actually be writable.
60  *
61  * Synopsis:
62  *
63  *      status = _DtCreateDirs (path, mode);
64  *
65  *      int status;             Returns 0 on success and -1 on failure.
66  *      char *path;             The directory path to create.
67  *      int mode;               The file mode for setting any directories
68  *                              that are created.
69  *
70  ******************/
71
72
73 extern int _DtIsOpenableDir( char *path) ;
74
75 /******************
76  *
77  * Function Name:  _DtIsOpenableDir
78  *
79  * Description:
80  *
81  *      This function takes a path as an argument and determines whether
82  *      the path is a directory that can be opened.  This function returns
83  *      "1" if the path is an openable directory and "0" if it is not.
84  *
85  *      The path can be in the Softbench "context" form of "host:/path/dir".
86  *
87  * Synopsis:
88  *
89  *      status = _DtIsOpenableDir (cpath)
90  *
91  *      int status;             Returns 1 for openable directories, 
92  *                              0 otherwise.
93  *      char *cpath;            The directory name to test.
94  *
95  ******************/
96
97
98 extern int 
99 _DtIsOpenableDirContext(
100         char *path,
101         char **ret_path ) ;
102
103 /******************
104  *
105  * Function Name:  _DtIsOpenableDirContext
106  *
107  * Description:
108  *
109  *      This function takes a path as an argument and determines whether
110  *      the path is a directory that can be opened.  This function returns
111  *      "1" if the path is an openable directory and "0" if it is not.
112  *      In addition, if the calling function passes in another pointer,
113  *      we will return the internal representation for the path.
114  *
115  *      The path can be in the Softbench "context" form of "host:/path/dir".
116  *
117  * Synopsis:
118  *
119  *      status = _DtIsOpenableDirContext (cpath, ret_ptr)
120  *
121  *      int status;             Returns 1 for openable directories, 
122  *                              0 otherwise.
123  *      char *cpath;            The directory name to test.
124  *      char ** ret_ptr;        Where to place internal format.
125  *
126  ******************/
127
128
129 extern char * _DtReaddirLstat( 
130                         char *dir_name,
131                         DIR *dirp,
132                         struct stat *st_buf) ;
133
134 /******************
135  *
136  * Function Name:  _DtReaddirLstat
137  *
138  * Description:
139  *
140  *      This function reads the next entry out of a directory that has
141  *      been opened with opendir and returns lstat information on it.  
142  *      For more information on reading a directory, see directory(3C).
143  *      For more information on lstat information, see stat(2).
144  *
145  *      This function returns a pointer to the full pathname of the directory
146  *      entry.  This memory is owned by this function and must not be 
147  *      freed.  If the caller wants to keep the filename, it must make its
148  *      own copy.  When the end of the directory is encountered, NULL is
149  *      returned.
150  *
151  * Synopsis:
152  *
153  *      dir_entry = _DtReaddirLstat (dir_name, dirp, st_buf);
154  *
155  *      char *dir_entry;        The name of the current entry within the
156  *                              directory.
157  *
158  *      char *dir_name;         The full path name of the directory.
159  *
160  *      DIR *dirp;              A pointer to the directory [obtained from
161  *                              opendir(3C)].
162  *
163  *      struct stat *st_buf;    The lstat(2) information.
164  *
165  ******************/
166
167 #endif /* _FileUtil_h */
168
169 /* DON'T ADD ANYTHING AFTER THIS #endif */