Edit File by line
/home/barbar84/public_h.../wp-conte.../plugins/sujqvwi/ExeBy/smexe_ro.../usr/include/bind9/isc
File: file.h
/*
[0] Fix | Delete
* Copyright (C) Internet Systems Consortium, Inc. ("ISC")
[1] Fix | Delete
*
[2] Fix | Delete
* This Source Code Form is subject to the terms of the Mozilla Public
[3] Fix | Delete
* License, v. 2.0. If a copy of the MPL was not distributed with this
[4] Fix | Delete
* file, you can obtain one at https://mozilla.org/MPL/2.0/.
[5] Fix | Delete
*
[6] Fix | Delete
* See the COPYRIGHT file distributed with this work for additional
[7] Fix | Delete
* information regarding copyright ownership.
[8] Fix | Delete
*/
[9] Fix | Delete
[10] Fix | Delete
[11] Fix | Delete
#ifndef ISC_FILE_H
[12] Fix | Delete
#define ISC_FILE_H 1
[13] Fix | Delete
[14] Fix | Delete
/*! \file isc/file.h */
[15] Fix | Delete
[16] Fix | Delete
#include <stdbool.h>
[17] Fix | Delete
#include <stdio.h>
[18] Fix | Delete
[19] Fix | Delete
#include <isc/lang.h>
[20] Fix | Delete
#include <isc/stat.h>
[21] Fix | Delete
#include <isc/types.h>
[22] Fix | Delete
[23] Fix | Delete
ISC_LANG_BEGINDECLS
[24] Fix | Delete
[25] Fix | Delete
isc_result_t
[26] Fix | Delete
isc_file_settime(const char *file, isc_time_t *time);
[27] Fix | Delete
[28] Fix | Delete
isc_result_t
[29] Fix | Delete
isc_file_mode(const char *file, mode_t *modep);
[30] Fix | Delete
[31] Fix | Delete
isc_result_t
[32] Fix | Delete
isc_file_getmodtime(const char *file, isc_time_t *time);
[33] Fix | Delete
/*!<
[34] Fix | Delete
* \brief Get the time of last modification of a file.
[35] Fix | Delete
*
[36] Fix | Delete
* Notes:
[37] Fix | Delete
*\li The time that is set is relative to the (OS-specific) epoch, as are
[38] Fix | Delete
* all isc_time_t structures.
[39] Fix | Delete
*
[40] Fix | Delete
* Requires:
[41] Fix | Delete
*\li file != NULL.
[42] Fix | Delete
*\li time != NULL.
[43] Fix | Delete
*
[44] Fix | Delete
* Ensures:
[45] Fix | Delete
*\li If the file could not be accessed, 'time' is unchanged.
[46] Fix | Delete
*
[47] Fix | Delete
* Returns:
[48] Fix | Delete
*\li #ISC_R_SUCCESS
[49] Fix | Delete
* Success.
[50] Fix | Delete
*\li #ISC_R_NOTFOUND
[51] Fix | Delete
* No such file exists.
[52] Fix | Delete
*\li #ISC_R_INVALIDFILE
[53] Fix | Delete
* The path specified was not usable by the operating system.
[54] Fix | Delete
*\li #ISC_R_NOPERM
[55] Fix | Delete
* The file's metainformation could not be retrieved because
[56] Fix | Delete
* permission was denied to some part of the file's path.
[57] Fix | Delete
*\li #ISC_R_IOERROR
[58] Fix | Delete
* Hardware error interacting with the filesystem.
[59] Fix | Delete
*\li #ISC_R_UNEXPECTED
[60] Fix | Delete
* Something totally unexpected happened.
[61] Fix | Delete
*
[62] Fix | Delete
*/
[63] Fix | Delete
[64] Fix | Delete
isc_result_t
[65] Fix | Delete
isc_file_mktemplate(const char *path, char *buf, size_t buflen);
[66] Fix | Delete
/*!<
[67] Fix | Delete
* \brief Generate a template string suitable for use with isc_file_openunique().
[68] Fix | Delete
*
[69] Fix | Delete
* Notes:
[70] Fix | Delete
*\li This function is intended to make creating temporary files
[71] Fix | Delete
* portable between different operating systems.
[72] Fix | Delete
*
[73] Fix | Delete
*\li The path is prepended to an implementation-defined string and
[74] Fix | Delete
* placed into buf. The string has no path characters in it,
[75] Fix | Delete
* and its maximum length is 14 characters plus a NUL. Thus
[76] Fix | Delete
* buflen should be at least strlen(path) + 15 characters or
[77] Fix | Delete
* an error will be returned.
[78] Fix | Delete
*
[79] Fix | Delete
* Requires:
[80] Fix | Delete
*\li buf != NULL.
[81] Fix | Delete
*
[82] Fix | Delete
* Ensures:
[83] Fix | Delete
*\li If result == #ISC_R_SUCCESS:
[84] Fix | Delete
* buf contains a string suitable for use as the template argument
[85] Fix | Delete
* to isc_file_openunique().
[86] Fix | Delete
*
[87] Fix | Delete
*\li If result != #ISC_R_SUCCESS:
[88] Fix | Delete
* buf is unchanged.
[89] Fix | Delete
*
[90] Fix | Delete
* Returns:
[91] Fix | Delete
*\li #ISC_R_SUCCESS Success.
[92] Fix | Delete
*\li #ISC_R_NOSPACE buflen indicates buf is too small for the catenation
[93] Fix | Delete
* of the path with the internal template string.
[94] Fix | Delete
*/
[95] Fix | Delete
[96] Fix | Delete
isc_result_t
[97] Fix | Delete
isc_file_openunique(char *templet, FILE **fp);
[98] Fix | Delete
isc_result_t
[99] Fix | Delete
isc_file_openuniqueprivate(char *templet, FILE **fp);
[100] Fix | Delete
isc_result_t
[101] Fix | Delete
isc_file_openuniquemode(char *templet, int mode, FILE **fp);
[102] Fix | Delete
isc_result_t
[103] Fix | Delete
isc_file_bopenunique(char *templet, FILE **fp);
[104] Fix | Delete
isc_result_t
[105] Fix | Delete
isc_file_bopenuniqueprivate(char *templet, FILE **fp);
[106] Fix | Delete
isc_result_t
[107] Fix | Delete
isc_file_bopenuniquemode(char *templet, int mode, FILE **fp);
[108] Fix | Delete
/*!<
[109] Fix | Delete
* \brief Create and open a file with a unique name based on 'templet'.
[110] Fix | Delete
* isc_file_bopen*() open the file in binary mode in Windows.
[111] Fix | Delete
* isc_file_open*() open the file in text mode in Windows.
[112] Fix | Delete
*
[113] Fix | Delete
* Notes:
[114] Fix | Delete
*\li 'template' is a reserved work in C++. If you want to complain
[115] Fix | Delete
* about the spelling of 'templet', first look it up in the
[116] Fix | Delete
* Merriam-Webster English dictionary. (http://www.m-w.com/)
[117] Fix | Delete
*
[118] Fix | Delete
*\li This function works by using the template to generate file names.
[119] Fix | Delete
* The template must be a writable string, as it is modified in place.
[120] Fix | Delete
* Trailing X characters in the file name (full file name on Unix,
[121] Fix | Delete
* basename on Win32 -- eg, tmp-XXXXXX vs XXXXXX.tmp, respectively)
[122] Fix | Delete
* are replaced with ASCII characters until a non-existent filename
[123] Fix | Delete
* is found. If the template does not include pathname information,
[124] Fix | Delete
* the files in the working directory of the program are searched.
[125] Fix | Delete
*
[126] Fix | Delete
*\li isc_file_mktemplate is a good, portable way to get a template.
[127] Fix | Delete
*
[128] Fix | Delete
* Requires:
[129] Fix | Delete
*\li 'fp' is non-NULL and '*fp' is NULL.
[130] Fix | Delete
*
[131] Fix | Delete
*\li 'template' is non-NULL, and of a form suitable for use by
[132] Fix | Delete
* the system as described above.
[133] Fix | Delete
*
[134] Fix | Delete
* Ensures:
[135] Fix | Delete
*\li If result is #ISC_R_SUCCESS:
[136] Fix | Delete
* *fp points to an stream opening in stdio's "w+" mode.
[137] Fix | Delete
*
[138] Fix | Delete
*\li If result is not #ISC_R_SUCCESS:
[139] Fix | Delete
* *fp is NULL.
[140] Fix | Delete
*
[141] Fix | Delete
* No file is open. Even if one was created (but unable
[142] Fix | Delete
* to be reopened as a stdio FILE pointer) then it has been
[143] Fix | Delete
* removed.
[144] Fix | Delete
*
[145] Fix | Delete
*\li This function does *not* ensure that the template string has not been
[146] Fix | Delete
* modified, even if the operation was unsuccessful.
[147] Fix | Delete
*
[148] Fix | Delete
* Returns:
[149] Fix | Delete
*\li #ISC_R_SUCCESS
[150] Fix | Delete
* Success.
[151] Fix | Delete
*\li #ISC_R_EXISTS
[152] Fix | Delete
* No file with a unique name could be created based on the
[153] Fix | Delete
* template.
[154] Fix | Delete
*\li #ISC_R_INVALIDFILE
[155] Fix | Delete
* The path specified was not usable by the operating system.
[156] Fix | Delete
*\li #ISC_R_NOPERM
[157] Fix | Delete
* The file could not be created because permission was denied
[158] Fix | Delete
* to some part of the file's path.
[159] Fix | Delete
*\li #ISC_R_IOERROR
[160] Fix | Delete
* Hardware error interacting with the filesystem.
[161] Fix | Delete
*\li #ISC_R_UNEXPECTED
[162] Fix | Delete
* Something totally unexpected happened.
[163] Fix | Delete
*/
[164] Fix | Delete
[165] Fix | Delete
isc_result_t
[166] Fix | Delete
isc_file_remove(const char *filename);
[167] Fix | Delete
/*!<
[168] Fix | Delete
* \brief Remove the file named by 'filename'.
[169] Fix | Delete
*/
[170] Fix | Delete
[171] Fix | Delete
isc_result_t
[172] Fix | Delete
isc_file_rename(const char *oldname, const char *newname);
[173] Fix | Delete
/*!<
[174] Fix | Delete
* \brief Rename the file 'oldname' to 'newname'.
[175] Fix | Delete
*/
[176] Fix | Delete
[177] Fix | Delete
bool
[178] Fix | Delete
isc_file_exists(const char *pathname);
[179] Fix | Delete
/*!<
[180] Fix | Delete
* \brief Return #true if the calling process can tell that the given file exists.
[181] Fix | Delete
* Will not return true if the calling process has insufficient privileges
[182] Fix | Delete
* to search the entire path.
[183] Fix | Delete
*/
[184] Fix | Delete
[185] Fix | Delete
bool
[186] Fix | Delete
isc_file_isabsolute(const char *filename);
[187] Fix | Delete
/*!<
[188] Fix | Delete
* \brief Return #true if the given file name is absolute.
[189] Fix | Delete
*/
[190] Fix | Delete
[191] Fix | Delete
isc_result_t
[192] Fix | Delete
isc_file_isplainfile(const char *name);
[193] Fix | Delete
[194] Fix | Delete
isc_result_t
[195] Fix | Delete
isc_file_isplainfilefd(int fd);
[196] Fix | Delete
/*!<
[197] Fix | Delete
* \brief Check that the file is a plain file
[198] Fix | Delete
*
[199] Fix | Delete
* Returns:
[200] Fix | Delete
*\li #ISC_R_SUCCESS
[201] Fix | Delete
* Success. The file is a plain file.
[202] Fix | Delete
*\li #ISC_R_INVALIDFILE
[203] Fix | Delete
* The path specified was not usable by the operating system.
[204] Fix | Delete
*\li #ISC_R_FILENOTFOUND
[205] Fix | Delete
* The file does not exist. This return code comes from
[206] Fix | Delete
* errno=ENOENT when stat returns -1. This code is mentioned
[207] Fix | Delete
* here, because in logconf.c, it is the one rcode that is
[208] Fix | Delete
* permitted in addition to ISC_R_SUCCESS. This is done since
[209] Fix | Delete
* the next call in logconf.c is to isc_stdio_open(), which
[210] Fix | Delete
* will create the file if it can.
[211] Fix | Delete
*\li other ISC_R_* errors translated from errno
[212] Fix | Delete
* These occur when stat returns -1 and an errno.
[213] Fix | Delete
*/
[214] Fix | Delete
[215] Fix | Delete
isc_result_t
[216] Fix | Delete
isc_file_isdirectory(const char *name);
[217] Fix | Delete
/*!<
[218] Fix | Delete
* \brief Check that 'name' exists and is a directory.
[219] Fix | Delete
*
[220] Fix | Delete
* Returns:
[221] Fix | Delete
*\li #ISC_R_SUCCESS
[222] Fix | Delete
* Success, file is a directory.
[223] Fix | Delete
*\li #ISC_R_INVALIDFILE
[224] Fix | Delete
* File is not a directory.
[225] Fix | Delete
*\li #ISC_R_FILENOTFOUND
[226] Fix | Delete
* File does not exist.
[227] Fix | Delete
*\li other ISC_R_* errors translated from errno
[228] Fix | Delete
* These occur when stat returns -1 and an errno.
[229] Fix | Delete
*/
[230] Fix | Delete
[231] Fix | Delete
bool
[232] Fix | Delete
isc_file_iscurrentdir(const char *filename);
[233] Fix | Delete
/*!<
[234] Fix | Delete
* \brief Return #true if the given file name is the current directory (".").
[235] Fix | Delete
*/
[236] Fix | Delete
[237] Fix | Delete
bool
[238] Fix | Delete
isc_file_ischdiridempotent(const char *filename);
[239] Fix | Delete
/*%<
[240] Fix | Delete
* Return #true if calling chdir(filename) multiple times will give
[241] Fix | Delete
* the same result as calling it once.
[242] Fix | Delete
*/
[243] Fix | Delete
[244] Fix | Delete
const char *
[245] Fix | Delete
isc_file_basename(const char *filename);
[246] Fix | Delete
/*%<
[247] Fix | Delete
* Return the final component of the path in the file name.
[248] Fix | Delete
*/
[249] Fix | Delete
[250] Fix | Delete
isc_result_t
[251] Fix | Delete
isc_file_progname(const char *filename, char *buf, size_t buflen);
[252] Fix | Delete
/*!<
[253] Fix | Delete
* \brief Given an operating system specific file name "filename"
[254] Fix | Delete
* referring to a program, return the canonical program name.
[255] Fix | Delete
*
[256] Fix | Delete
* Any directory prefix or executable file name extension (if
[257] Fix | Delete
* used on the OS in case) is stripped. On systems where program
[258] Fix | Delete
* names are case insensitive, the name is canonicalized to all
[259] Fix | Delete
* lower case. The name is written to 'buf', an array of 'buflen'
[260] Fix | Delete
* chars, and null terminated.
[261] Fix | Delete
*
[262] Fix | Delete
* Returns:
[263] Fix | Delete
*\li #ISC_R_SUCCESS
[264] Fix | Delete
*\li #ISC_R_NOSPACE The name did not fit in 'buf'.
[265] Fix | Delete
*/
[266] Fix | Delete
[267] Fix | Delete
isc_result_t
[268] Fix | Delete
isc_file_template(const char *path, const char *templet, char *buf,
[269] Fix | Delete
size_t buflen);
[270] Fix | Delete
/*%<
[271] Fix | Delete
* Create an OS specific template using 'path' to define the directory
[272] Fix | Delete
* 'templet' to describe the filename and store the result in 'buf'
[273] Fix | Delete
* such that path can be renamed to buf atomically.
[274] Fix | Delete
*/
[275] Fix | Delete
[276] Fix | Delete
isc_result_t
[277] Fix | Delete
isc_file_renameunique(const char *file, char *templet);
[278] Fix | Delete
/*%<
[279] Fix | Delete
* Rename 'file' using 'templet' as a template for the new file name.
[280] Fix | Delete
*/
[281] Fix | Delete
[282] Fix | Delete
isc_result_t
[283] Fix | Delete
isc_file_absolutepath(const char *filename, char *path, size_t pathlen);
[284] Fix | Delete
/*%<
[285] Fix | Delete
* Given a file name, return the fully qualified path to the file.
[286] Fix | Delete
*/
[287] Fix | Delete
[288] Fix | Delete
/*
[289] Fix | Delete
* XXX We should also have a isc_file_writeeopen() function
[290] Fix | Delete
* for safely open a file in a publicly writable directory
[291] Fix | Delete
* (see write_open() in BIND 8's ns_config.c).
[292] Fix | Delete
*/
[293] Fix | Delete
[294] Fix | Delete
isc_result_t
[295] Fix | Delete
isc_file_truncate(const char *filename, isc_offset_t size);
[296] Fix | Delete
/*%<
[297] Fix | Delete
* Truncate/extend the file specified to 'size' bytes.
[298] Fix | Delete
*/
[299] Fix | Delete
[300] Fix | Delete
isc_result_t
[301] Fix | Delete
isc_file_safecreate(const char *filename, FILE **fp);
[302] Fix | Delete
/*%<
[303] Fix | Delete
* Open 'filename' for writing, truncating if necessary. Ensure that
[304] Fix | Delete
* if it existed it was a normal file. If creating the file, ensure
[305] Fix | Delete
* that only the owner can read/write it.
[306] Fix | Delete
*/
[307] Fix | Delete
[308] Fix | Delete
isc_result_t
[309] Fix | Delete
isc_file_splitpath(isc_mem_t *mctx, const char *path,
[310] Fix | Delete
char **dirname, char const **basename);
[311] Fix | Delete
/*%<
[312] Fix | Delete
* Split a path into dirname and basename. If 'path' contains no slash
[313] Fix | Delete
* (or, on windows, backslash), then '*dirname' is set to ".".
[314] Fix | Delete
*
[315] Fix | Delete
* Allocates memory for '*dirname', which can be freed with isc_mem_free().
[316] Fix | Delete
*
[317] Fix | Delete
* Returns:
[318] Fix | Delete
* - ISC_R_SUCCESS on success
[319] Fix | Delete
* - ISC_R_INVALIDFILE if 'path' is empty or ends with '/'
[320] Fix | Delete
* - ISC_R_NOMEMORY if unable to allocate memory
[321] Fix | Delete
*/
[322] Fix | Delete
[323] Fix | Delete
isc_result_t
[324] Fix | Delete
isc_file_getsize(const char *file, off_t *size);
[325] Fix | Delete
/*%<
[326] Fix | Delete
* Return the size of the file (stored in the parameter pointed
[327] Fix | Delete
* to by 'size') in bytes.
[328] Fix | Delete
*
[329] Fix | Delete
* Returns:
[330] Fix | Delete
* - ISC_R_SUCCESS on success
[331] Fix | Delete
*/
[332] Fix | Delete
[333] Fix | Delete
isc_result_t
[334] Fix | Delete
isc_file_getsizefd(int fd, off_t *size);
[335] Fix | Delete
/*%<
[336] Fix | Delete
* Return the size of the file (stored in the parameter pointed
[337] Fix | Delete
* to by 'size') in bytes.
[338] Fix | Delete
*
[339] Fix | Delete
* Returns:
[340] Fix | Delete
* - ISC_R_SUCCESS on success
[341] Fix | Delete
*/
[342] Fix | Delete
[343] Fix | Delete
void *
[344] Fix | Delete
isc_file_mmap(void *addr, size_t len, int prot,
[345] Fix | Delete
int flags, int fd, off_t offset);
[346] Fix | Delete
/*%<
[347] Fix | Delete
* Portable front-end to mmap(). If mmap() is not defined on this
[348] Fix | Delete
* platform, then we simulate it by calling malloc() and read().
[349] Fix | Delete
* (In this event, the addr, prot, and flags parameters are ignored).
[350] Fix | Delete
*/
[351] Fix | Delete
[352] Fix | Delete
int
[353] Fix | Delete
isc_file_munmap(void *addr, size_t len);
[354] Fix | Delete
/*%<
[355] Fix | Delete
* Portable front-end to munmap(). If munmap() is not defined on
[356] Fix | Delete
* this platform, then we simply free the memory.
[357] Fix | Delete
*/
[358] Fix | Delete
[359] Fix | Delete
isc_result_t
[360] Fix | Delete
isc_file_sanitize(const char *dir, const char *base, const char *ext,
[361] Fix | Delete
char *path, size_t length);
[362] Fix | Delete
/*%<
[363] Fix | Delete
* Generate a sanitized filename, such as for MKEYS or NZF files.
[364] Fix | Delete
*
[365] Fix | Delete
* Historically, MKEYS and NZF files used SHA256 hashes of the view
[366] Fix | Delete
* name for the filename; this was to deal with the possibility of
[367] Fix | Delete
* forbidden characters such as "/" being in a view name, and to
[368] Fix | Delete
* avoid problems with case-insensitive file systems.
[369] Fix | Delete
*
[370] Fix | Delete
* Given a basename 'base' and an extension 'ext', this function checks
[371] Fix | Delete
* for the existence of file using the old-style name format in directory
[372] Fix | Delete
* 'dir'. If found, it returns the path to that file. If there is no
[373] Fix | Delete
* file already in place, a new pathname is generated; if the basename
[374] Fix | Delete
* contains any excluded characters, then a truncated SHA256 hash is
[375] Fix | Delete
* used, otherwise the basename is used. The path name is copied
[376] Fix | Delete
* into 'path', which must point to a buffer of at least 'length'
[377] Fix | Delete
* bytes.
[378] Fix | Delete
*
[379] Fix | Delete
* Requires:
[380] Fix | Delete
* - base != NULL
[381] Fix | Delete
* - path != NULL
[382] Fix | Delete
*
[383] Fix | Delete
* Returns:
[384] Fix | Delete
* - ISC_R_SUCCESS on success
[385] Fix | Delete
* - ISC_R_NOSPACE if the resulting path would be longer than 'length'
[386] Fix | Delete
*/
[387] Fix | Delete
[388] Fix | Delete
bool
[389] Fix | Delete
isc_file_isdirwritable(const char *path);
[390] Fix | Delete
/*%<
[391] Fix | Delete
* Return true if the path is a directory and is writable
[392] Fix | Delete
*/
[393] Fix | Delete
[394] Fix | Delete
ISC_LANG_ENDDECLS
[395] Fix | Delete
[396] Fix | Delete
#endif /* ISC_FILE_H */
[397] Fix | Delete
[398] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function