~ubuntu-branches/ubuntu/maverick/bind9/maverick

« back to all changes in this revision

Viewing changes to lib/isc/include/isc/file.h

  • Committer: Bazaar Package Importer
  • Author(s): LaMont Jones, LaMont Jones, Internet Software Consortium, Inc, localization folks
  • Date: 2008-08-02 14:20:20 UTC
  • mfrom: (1.2.1 upstream) (6.1.24 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080802142020-l1hon9jy8lbbjxmg
[LaMont Jones]

* default to using resolvconf if it is installed
* fix sonames and dependencies.  Closes: #149259, #492418
* Do not build-depend libcap2-dev on non-linux.  Closes: #493392
* drop unused query-loc manpage.  Closes: #492564
* lwresd: Deliver /etc/bind directory.  Closes: #490027
* fix query-source comment in default install

[Internet Software Consortium, Inc]

* 9.5.0-P2.  Closes: #492949

[localization folks]

* l10n: Spanish debconf translation.  Closes: #492425 (Ignacio Mondino)
* l10n: Swedish debconf templates.  Closes: #491369 (Martin Ågren)
* l10n: Japanese debconf translations.  Closes: #492048 (Hideki Yamane
  (Debian-JP))
* l10n: Finnish translation.  Closes: #490630 (Esko Arajärvi)
* l10n: Italian debconf translations.  Closes: #492587 (Alessandro Vietta)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
 
2
 * Copyright (C) 2004-2007  Internet Systems Consortium, Inc. ("ISC")
3
3
 * Copyright (C) 2000, 2001  Internet Software Consortium.
4
4
 *
5
 
 * Permission to use, copy, modify, and distribute this software for any
 
5
 * Permission to use, copy, modify, and/or distribute this software for any
6
6
 * purpose with or without fee is hereby granted, provided that the above
7
7
 * copyright notice and this permission notice appear in all copies.
8
8
 *
15
15
 * PERFORMANCE OF THIS SOFTWARE.
16
16
 */
17
17
 
18
 
/* $Id: file.h,v 1.24.12.3 2004/03/08 09:04:51 marka Exp $ */
 
18
/* $Id: file.h,v 1.33 2007/06/19 23:47:18 tbox Exp $ */
19
19
 
20
20
#ifndef ISC_FILE_H
21
21
#define ISC_FILE_H 1
22
22
 
 
23
/*! \file isc/file.h */
 
24
 
23
25
#include <stdio.h>
24
26
 
25
27
#include <isc/lang.h>
32
34
 
33
35
isc_result_t
34
36
isc_file_getmodtime(const char *file, isc_time_t *time);
35
 
/*
36
 
 * Get the time of last modication of a file.
 
37
/*!<
 
38
 * \brief Get the time of last modication of a file.
37
39
 *
38
40
 * Notes:
39
 
 *      The time that is set is relative to the (OS-specific) epoch, as are
 
41
 *\li   The time that is set is relative to the (OS-specific) epoch, as are
40
42
 *      all isc_time_t structures.
41
43
 *
42
44
 * Requires:
43
 
 *      file != NULL.
44
 
 *      time != NULL.
 
45
 *\li   file != NULL.
 
46
 *\li   time != NULL.
45
47
 *
46
48
 * Ensures:
47
 
 *      If the file could not be accessed, 'time' is unchanged.
 
49
 *\li   If the file could not be accessed, 'time' is unchanged.
48
50
 *
49
51
 * Returns:
50
 
 *      ISC_R_SUCCESS
 
52
 *\li   #ISC_R_SUCCESS
51
53
 *              Success.
52
 
 *      ISC_R_NOTFOUND
 
54
 *\li   #ISC_R_NOTFOUND
53
55
 *              No such file exists.
54
 
 *      ISC_R_INVALIDFILE
 
56
 *\li   #ISC_R_INVALIDFILE
55
57
 *              The path specified was not usable by the operating system.
56
 
 *      ISC_R_NOPERM
 
58
 *\li   #ISC_R_NOPERM
57
59
 *              The file's metainformation could not be retrieved because
58
60
 *              permission was denied to some part of the file's path.
59
 
 *      ISC_R_EIO
 
61
 *\li   #ISC_R_EIO
60
62
 *              Hardware error interacting with the filesystem.
61
 
 *      ISC_R_UNEXPECTED
 
63
 *\li   #ISC_R_UNEXPECTED
62
64
 *              Something totally unexpected happened.
63
65
 *
64
66
 */
65
67
 
66
68
isc_result_t
67
69
isc_file_mktemplate(const char *path, char *buf, size_t buflen);
68
 
/*
69
 
 * Generate a template string suitable for use with isc_file_openunique.
 
70
/*!<
 
71
 * \brief Generate a template string suitable for use with isc_file_openunique().
70
72
 *
71
73
 * Notes:
72
 
 *      This function is intended to make creating temporary files
 
74
 *\li   This function is intended to make creating temporary files
73
75
 *      portable between different operating systems.
74
76
 *
75
 
 *      The path is prepended to an implementation-defined string and
 
77
 *\li   The path is prepended to an implementation-defined string and
76
78
 *      placed into buf.  The string has no path characters in it,
77
79
 *      and its maximum length is 14 characters plus a NUL.  Thus
78
80
 *      buflen should be at least strlen(path) + 15 characters or
79
81
 *      an error will be returned.
80
82
 *
81
83
 * Requires:
82
 
 *      buf != NULL.
 
84
 *\li   buf != NULL.
83
85
 *
84
86
 * Ensures:
85
 
 *      If result == ISC_R_SUCCESS:
 
87
 *\li   If result == #ISC_R_SUCCESS:
86
88
 *              buf contains a string suitable for use as the template argument
87
 
 *              to isc_file_openunique.
 
89
 *              to isc_file_openunique().
88
90
 *
89
 
 *      If result != ISC_R_SUCCESS:
 
91
 *\li   If result != #ISC_R_SUCCESS:
90
92
 *              buf is unchanged.
91
93
 *
92
94
 * Returns:
93
 
 *      ISC_R_SUCCESS   Success.
94
 
 *      ISC_R_NOSPACE   buflen indicates buf is too small for the catenation
 
95
 *\li   #ISC_R_SUCCESS  Success.
 
96
 *\li   #ISC_R_NOSPACE  buflen indicates buf is too small for the catenation
95
97
 *                              of the path with the internal template string.
96
98
 */
97
99
 
98
100
 
99
101
isc_result_t
100
102
isc_file_openunique(char *templet, FILE **fp);
101
 
/*
102
 
 * Create and open a file with a unique name based on 'templet'.
 
103
/*!<
 
104
 * \brief Create and open a file with a unique name based on 'templet'.
103
105
 *
104
106
 * Notes:
105
 
 *      'template' is a reserved work in C++.  If you want to complain
 
107
 *\li   'template' is a reserved work in C++.  If you want to complain
106
108
 *      about the spelling of 'templet', first look it up in the
107
109
 *      Merriam-Webster English dictionary. (http://www.m-w.com/)
108
110
 *
109
 
 *      This function works by using the template to generate file names.
 
111
 *\li   This function works by using the template to generate file names.
110
112
 *      The template must be a writable string, as it is modified in place.
111
113
 *      Trailing X characters in the file name (full file name on Unix,
112
114
 *      basename on Win32 -- eg, tmp-XXXXXX vs XXXXXX.tmp, respectively)
114
116
 *      is found.  If the template does not include pathname information,
115
117
 *      the files in the working directory of the program are searched.
116
118
 *
117
 
 *      isc_file_mktemplate is a good, portable way to get a template.
 
119
 *\li   isc_file_mktemplate is a good, portable way to get a template.
118
120
 *
119
121
 * Requires:
120
 
 *      'fp' is non-NULL and '*fp' is NULL.
 
122
 *\li   'fp' is non-NULL and '*fp' is NULL.
121
123
 *
122
 
 *      'template' is non-NULL, and of a form suitable for use by
 
124
 *\li   'template' is non-NULL, and of a form suitable for use by
123
125
 *      the system as described above.
124
126
 *
125
127
 * Ensures:
126
 
 *      If result is ISC_R_SUCCESS:
 
128
 *\li   If result is #ISC_R_SUCCESS:
127
129
 *              *fp points to an stream opening in stdio's "w+" mode.
128
130
 *
129
 
 *      If result is not ISC_R_SUCCESS:
 
131
 *\li   If result is not #ISC_R_SUCCESS:
130
132
 *              *fp is NULL.
131
133
 *
132
134
 *              No file is open.  Even if one was created (but unable
133
135
 *              to be reopened as a stdio FILE pointer) then it has been
134
136
 *              removed.
135
137
 *
136
 
 *      This function does *not* ensure that the template string has not been
 
138
 *\li   This function does *not* ensure that the template string has not been
137
139
 *      modified, even if the operation was unsuccessful.
138
140
 *
139
141
 * Returns:
140
 
 *      ISC_R_SUCCESS
 
142
 *\li   #ISC_R_SUCCESS
141
143
 *              Success.
142
 
 *      ISC_R_EXISTS
 
144
 *\li   #ISC_R_EXISTS
143
145
 *              No file with a unique name could be created based on the
144
146
 *              template.
145
 
 *      ISC_R_INVALIDFILE
 
147
 *\li   #ISC_R_INVALIDFILE
146
148
 *              The path specified was not usable by the operating system.
147
 
 *      ISC_R_NOPERM
 
149
 *\li   #ISC_R_NOPERM
148
150
 *              The file could not be created because permission was denied
149
151
 *              to some part of the file's path.
150
 
 *      ISC_R_EIO
 
152
 *\li   #ISC_R_IOERROR
151
153
 *              Hardware error interacting with the filesystem.
152
 
 *      ISC_R_UNEXPECTED
 
154
 *\li   #ISC_R_UNEXPECTED
153
155
 *              Something totally unexpected happened.
154
156
 */
155
157
 
156
158
isc_result_t
157
159
isc_file_remove(const char *filename);
158
 
/*
159
 
 * Remove the file named by 'filename'.
 
160
/*!<
 
161
 * \brief Remove the file named by 'filename'.
160
162
 */
161
163
 
162
164
isc_result_t
163
165
isc_file_rename(const char *oldname, const char *newname);
164
 
/*
165
 
 * Rename the file 'oldname' to 'newname'.
 
166
/*!<
 
167
 * \brief Rename the file 'oldname' to 'newname'.
166
168
 */
167
169
 
168
170
isc_boolean_t
169
171
isc_file_exists(const char *pathname);
170
 
/*
171
 
 * Return ISC_TRUE iff the calling process can tell that the given file exists.
 
172
/*!<
 
173
 * \brief Return #ISC_TRUE if the calling process can tell that the given file exists.
172
174
 * Will not return true if the calling process has insufficient privileges
173
175
 * to search the entire path.
174
176
 */
175
177
 
176
178
isc_boolean_t
177
179
isc_file_isabsolute(const char *filename);
178
 
/*
179
 
 * Return ISC_TRUE iff the given file name is absolute.
 
180
/*!<
 
181
 * \brief Return #ISC_TRUE if the given file name is absolute.
180
182
 */
181
183
 
182
184
isc_boolean_t
183
185
isc_file_iscurrentdir(const char *filename);
184
 
/*
185
 
 * Return ISC_TRUE iff the given file name is the current directory (".").
 
186
/*!<
 
187
 * \brief Return #ISC_TRUE if the given file name is the current directory (".").
186
188
 */
187
189
 
188
190
isc_boolean_t
189
191
isc_file_ischdiridempotent(const char *filename);
190
 
/*
191
 
 * Return ISC_TRUE if calling chdir(filename) multiple times will give
 
192
/*%<
 
193
 * Return #ISC_TRUE if calling chdir(filename) multiple times will give
192
194
 * the same result as calling it once.
193
195
 */
194
196
 
195
197
const char *
196
198
isc_file_basename(const char *filename);
197
 
/*
 
199
/*%<
198
200
 * Return the final component of the path in the file name.
199
201
 */
200
202
 
201
203
isc_result_t
202
204
isc_file_progname(const char *filename, char *buf, size_t buflen);
203
 
/*
204
 
 * Given an operating system specific file name "filename"
 
205
/*!<
 
206
 * \brief Given an operating system specific file name "filename"
205
207
 * referring to a program, return the canonical program name. 
 
208
 *
 
209
 *
206
210
 * Any directory prefix or executable file name extension (if
207
211
 * used on the OS in case) is stripped.  On systems where program
208
212
 * names are case insensitive, the name is canonicalized to all
210
214
 * chars, and null terminated.
211
215
 *
212
216
 * Returns:
213
 
 *      ISC_R_SUCCESS
214
 
 *      ISC_R_NOSPACE   The name did not fit in 'buf'.
 
217
 *\li   #ISC_R_SUCCESS
 
218
 *\li   #ISC_R_NOSPACE  The name did not fit in 'buf'.
215
219
 */
216
220
 
217
221
isc_result_t
218
222
isc_file_template(const char *path, const char *templet, char *buf,
219
223
                  size_t buflen);
220
 
/*
 
224
/*%<
221
225
 * Create an OS specific template using 'path' to define the directory
222
226
 * 'templet' to describe the filename and store the result in 'buf'
223
227
 * such that path can be renamed to buf atomically.
225
229
 
226
230
isc_result_t
227
231
isc_file_renameunique(const char *file, char *templet);
228
 
/*
 
232
/*%<
229
233
 * Rename 'file' using 'templet' as a template for the new file name.
230
234
 */
231
235
 
232
236
isc_result_t
233
237
isc_file_absolutepath(const char *filename, char *path, size_t pathlen);
234
 
/*
 
238
/*%<
235
239
 * Given a file name, return the fully qualified path to the file.
236
240
 */
237
241
 
243
247
 
244
248
isc_result_t
245
249
isc_file_truncate(const char *filename, isc_offset_t size);
246
 
/*
 
250
/*%<
247
251
 * Truncate/extend the file specified to 'size' bytes.
248
252
 */
249
253