Fix Missing -z proto,colinfo,ip,gtp.teid_cp and -z proto,colinfo,ip,gtp.teid_data
[obnox/wireshark/wip.git] / epan / filesystem.h
1 /* filesystem.h
2  * Filesystem utility definitions
3  *
4  * $Id$
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (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, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
23  */
24
25 #ifndef FILESYSTEM_H
26 #define FILESYSTEM_H
27
28 /*
29  * Get the pathname of the directory from which the executable came,
30  * and save it for future use.  Returns NULL on success, and a
31  * g_mallocated string containing an error on failure.
32  */
33 extern char *init_progfile_dir(const char *arg0);
34
35 /*
36  * Get the directory in which the program resides.
37  */
38 extern const char *get_progfile_dir(void);
39
40 /*
41  * Get the directory in which plugins are stored; this must not be called
42  * before init_progfile_dir() is called, as they might be stored in a
43  * subdirectory of the program file directory.
44  */
45 extern const char *get_plugin_dir(void);
46
47 /*
48  * Get the flag indicating whether we're running from a build
49  * directory.
50  */
51 extern gboolean running_in_build_directory(void);
52
53 /*
54  * Get the directory in which global configuration files are
55  * stored.
56  */
57 extern const char *get_datafile_dir(void);
58
59 /*
60  * Construct the path name of a global configuration file, given the
61  * file name.
62  */
63 extern char *get_datafile_path(const char *filename);
64
65 /*
66  * Get the directory in which files that, at least on UNIX, are
67  * system files (such as "/etc/ethers") are stored; on Windows,
68  * there's no "/etc" directory, so we get them from the Wireshark
69  * global configuration and data file directory.
70  */
71 extern const char *get_systemfile_dir(void);
72
73 /*
74  * Create the directory that holds personal configuration files, if
75  * necessary.  If we attempted to create it, and failed, return -1 and
76  * set "*pf_dir_path_return" to the pathname of the directory we failed
77  * to create (it's g_mallocated, so our caller should free it); otherwise,
78  * return 0.
79  */
80 extern int create_persconffile_dir(char **pf_dir_path_return);
81
82 /*
83  * Construct the path name of a personal configuration file, given the
84  * file name.
85  *
86  * On Win32, if "for_writing" is FALSE, we check whether the file exists
87  * and, if not, construct a path name relative to the ".wireshark"
88  * subdirectory of the user's home directory, and check whether that
89  * exists; if it does, we return that, so that configuration files
90  * from earlier versions can be read.
91  */
92 extern char *get_persconffile_path(const char *filename, gboolean for_writing);
93
94 /*
95  * Get the (default) directory in which personal data is stored.
96  *
97  * On Win32, this is the "My Documents" folder in the personal profile.
98  * On UNIX this is simply the current directory.
99  */
100 extern char *get_persdatafile_dir(void);
101
102 /*
103  * Construct the path name of a file in $TMP/%TEMP% directory.
104  * Or "/tmp/<filename>" (C:\<filename>) if that fails.
105  *
106  * Return value is malloced so the caller should free it.
107  */
108 extern char *get_tempfile_path(const char *filename);
109
110 /* 
111  * process command line option belonging to the filesystem settings
112  */
113 extern int filesystem_opt(int opt, const char *optarg);
114
115 /*
116  * Return an error message for UNIX-style errno indications on open or
117  * create operations.
118  */
119 extern const char *file_open_error_message(int err, gboolean for_writing);
120
121 /*
122  * Return an error message for UNIX-style errno indications on write
123  * operations.
124  */
125 extern const char *file_write_error_message(int err);
126
127 /*
128  * Given a pathname, return the last component.
129  */
130 extern const char *get_basename(const char *);
131
132 /*
133  * Given a pathname, return a string containing everything but the
134  * last component.  NOTE: this overwrites the pathname handed into
135  * it....
136  */
137 extern char *get_dirname(char *);
138
139 /*
140  * Given a pathname, return:
141  *
142  *      the errno, if an attempt to "stat()" the file fails;
143  *
144  *      EISDIR, if the attempt succeeded and the file turned out
145  *      to be a directory;
146  *
147  *      0, if the attempt succeeded and the file turned out not
148  *      to be a directory.
149  */
150 extern int test_for_directory(const char *);
151
152 /*
153  * Given a pathname, return:
154  *
155  *      the errno, if an attempt to "stat()" the file fails;
156  *
157  *      ESPIPE, if the attempt succeeded and the file turned out
158  *      to be a FIFO;
159  *
160  *      0, if the attempt succeeded and the file turned out not
161  *      to be a FIFO.
162  */
163 extern int test_for_fifo(const char *);
164
165 /* Delete a file */
166 extern gboolean deletefile (const char *path);
167
168 /*
169  * Check, if file is existing.
170  */
171 extern gboolean file_exists(const char *fname);
172
173 /*
174  * Check, if two filenames are identical (with absolute and relative paths).
175  */
176 extern gboolean files_identical(const char *fname1, const char *fname2);
177
178 #ifdef WIN32
179 /*
180  * utf8 version of getenv, needed to get win32 filename paths
181  */
182 extern char *getenv_utf8(const char *varname);
183 #endif
184
185 #endif /* FILESYSTEM_H */