OpenDNSSEC-signer  1.3.9
Macros | Functions
file.h File Reference
#include "config.h"
#include "shared/status.h"
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
Include dependency graph for file.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define SYSTEM_MAXLEN   1024
 

Functions

const char * ods_file_mode2str (const char *mode)
 
int ods_fgetc (FILE *fd, unsigned int *line_nr)
 
int ods_skip_whitespace (FILE *fd, unsigned int *line_nr)
 
char * ods_build_path (const char *file, const char *suffix, int dir, int no_slash)
 
FILE * ods_fopen (const char *file, const char *dir, const char *mode)
 
void ods_fclose (FILE *fd)
 
ssize_t ods_writen (int fd, const void *vptr, size_t n)
 
time_t ods_file_lastmodified (const char *file)
 
int ods_strcmp (const char *s1, const char *s2)
 
const char * ods_replace (const char *str, const char *oldstr, const char *newstr)
 
char * ods_dir_name (const char *file)
 
ods_status ods_file_copy (const char *file1, const char *file2)
 
void ods_chown (const char *file, uid_t uid, gid_t gid, int getdir)
 
void ods_str_trim (char *str)
 

Macro Definition Documentation

#define SYSTEM_MAXLEN   1024

File access wrapper.

Definition at line 51 of file file.h.

Referenced by ods_replace(), tools_audit(), and tools_output().

Function Documentation

char* ods_build_path ( const char *  file,
const char *  suffix,
int  dir,
int  no_slash 
)

Construct file or directory name.

Parameters
[in]filefilename without extension
[in]suffixextension.
[in]dirdirectory or not
[in]no_slashno forward slashes and such characters allowed
Returns
char* concatenation of file and suffix

Construct file name. (StrAppend?, snprintf?)

Definition at line 124 of file file.c.

References ods_log_crit().

Referenced by adfile_write(), tools_audit(), tools_input(), zone_backup(), and zone_recover().

void ods_chown ( const char *  file,
uid_t  uid,
gid_t  gid,
int  getdir 
)

(Create) and change ownership of directories.

Parameters
[in]filefile name
[in]uiduser id
[in]gidgroup id
[in]getdirfetch directory part

(Create) and change ownership of directories

Definition at line 455 of file file.c.

References ods_dir_name(), ods_log_debug(), ods_log_error(), and ods_log_warning().

char* ods_dir_name ( const char *  file)

Get directory part of filename.

Parameters
[in]filefile name
Returns
char* directory part

Get directory part of filename.

Definition at line 424 of file file.c.

References ods_log_assert.

Referenced by ods_chown().

void ods_fclose ( FILE *  fd)
int ods_fgetc ( FILE *  fd,
unsigned int *  line_nr 
)

Get next character.

Parameters
[in]fdfile descriptor
[in]line_nrline number
Returns
int next character.

Get next char.

Definition at line 79 of file file.c.

References ods_log_assert.

Referenced by adutil_readline_frm_file(), and ods_skip_whitespace().

ods_status ods_file_copy ( const char *  file1,
const char *  file2 
)

Copy file.

Parameters
[in]file1from file name
[in]file2to file name
Returns
ods_status

File copy.

Definition at line 381 of file file.c.

References BUFFER_SIZE, ODS_STATUS_ASSERT_ERR, ODS_STATUS_FOPEN_ERR, ODS_STATUS_FREAD_ERR, ODS_STATUS_FWRITE_ERR, and ODS_STATUS_OK.

Referenced by tools_input().

time_t ods_file_lastmodified ( const char *  file)

Get file status.

Parameters
[in]filefile name
Returns
time_t last modified

Get file last modified.

Definition at line 280 of file file.c.

References ods_fclose(), ods_fopen(), and ods_log_assert.

Referenced by signconf_update(), and zonelist_update().

const char* ods_file_mode2str ( const char *  mode)

Convert file mode to readable string.

Parameters
[in]modefile mode
Returns
const char* string

Convert file mode to readable string.

Definition at line 57 of file file.c.

References ods_strcmp().

Referenced by ods_fopen().

FILE* ods_fopen ( const char *  file,
const char *  dir,
const char *  mode 
)

Open a file.

Parameters
[in]filefilename.
[in]dirdirectory.
[in]modefile mode
Returns
FILE* file descriptor

Open a file.

Definition at line 184 of file file.c.

References ods_file_mode2str(), ods_log_assert, ods_log_debug(), and ods_log_verbose().

Referenced by adbackup_read(), adfile_read(), adfile_write(), engine_config(), ods_file_lastmodified(), ods_log_init(), signconf_recover_from_backup(), task_recover_from_backup(), util_write_pidfile(), zone_backup(), and zone_recover().

const char* ods_replace ( const char *  str,
const char *  oldstr,
const char *  newstr 
)

Replace a substring in string.

Parameters
[in]strThe string
[in]oldstrold substring
[in]newstrnew substring
Returns
char* the substituted string.

Replace a substring in string.

Definition at line 324 of file file.c.

References SYSTEM_MAXLEN.

int ods_skip_whitespace ( FILE *  fd,
unsigned int *  line_nr 
)

Skip white space.

Parameters
[in]fdfile descriptor
[in]line_nrline number
Returns
int first encountered non-whitespace character

Skip white space.

Definition at line 102 of file file.c.

References ods_fgetc(), and ods_log_assert.

void ods_str_trim ( char *  str)

Remove leading and trailing whitespace.

Parameters
[in]strstring to trim

Remove leading and trailing whitespace.

Definition at line 491 of file file.c.

int ods_strcmp ( const char *  s1,
const char *  s2 
)

Compare strings.

Parameters
[in]s1one string
[in]s2another string
Returns
-1, 0 or 1

Compare strings.

Definition at line 302 of file file.c.

Referenced by adapter_compare(), backup_read_check_str(), domain_recover(), keylist_lookup(), main(), ods_file_mode2str(), parse_conf_adapters(), parse_zonelist_zones(), signconf_compare_denial(), zone_merge(), zone_recover(), zonedata_recover(), and zonedata_update_serial().

ssize_t ods_writen ( int  fd,
const void *  vptr,
size_t  n 
)

Write to file descriptor.

Parameters
[in]fdfile descriptor
[in]vptrpointer to data
[in]nsize of data

Write to file descriptor.

Definition at line 252 of file file.c.