OpenDNSSEC-signer 1.2.1
Defines | Functions

/build/buildd-opendnssec_1.2.1.dfsg-1-mips-p9AT07/opendnssec-1.2.1.dfsg/signer/src/util/file.h File Reference

#include "config.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.

Defines

#define SYSTEM_MAXLEN   1024

Functions

const char * se_file_mode2str (const char *mode)
int se_fgetc (FILE *fd, unsigned int *line_nr)
int se_skip_whitespace (FILE *fd, unsigned int *line_nr)
char * se_build_path (const char *file, const char *suffix, int dir)
FILE * se_fopen (const char *file, const char *dir, const char *mode)
void se_fclose (FILE *fd)
ssize_t se_writen (int fd, const void *vptr, size_t n)
time_t se_file_lastmodified (const char *file)
int se_strcmp (const char *s1, const char *s2)
const char * se_replace (const char *str, const char *oldstr, const char *newstr)
char * se_dir_name (const char *file)
int se_file_copy (const char *file1, const char *file2)
void se_chown (const char *file, uid_t uid, gid_t gid, int getdir)
void se_str_trim (char *str)

Define Documentation

#define SYSTEM_MAXLEN   1024

File access wrapper.

Definition at line 50 of file file.h.

Referenced by se_file_copy(), se_replace(), tools_audit(), and tools_write_output().


Function Documentation

char* se_build_path ( const char *  file,
const char *  suffix,
int  dir 
)

Construct file or directory name.

Parameters:
[in]filefilename without extension
[in]suffixextension.
[in]dirdirectory or not
Returns:
char* concatenation of file and suffix

Construct file name. (StrAppend?, snprintf?)

Definition at line 114 of file file.c.

References se_malloc().

Referenced by signconf_backup(), task_backup(), tools_audit(), tools_read_input(), tools_update(), zone_add_dnskeys(), zone_backup_state(), zone_nsecify(), zone_recover_from_backup(), and zone_sign().

void se_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 396 of file file.c.

References se_dir_name(), se_free(), se_log_debug(), se_log_error(), and se_log_warning().

char* se_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 367 of file file.c.

References se_calloc(), and se_log_assert.

Referenced by se_chown().

void se_fclose ( FILE *  fd)
int se_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 72 of file file.c.

References se_log_assert.

Referenced by se_skip_whitespace().

int se_file_copy ( const char *  file1,
const char *  file2 
)

Copy file.

Parameters:
[in]file1from file name
[in]file2to file name
Returns:
0 on success, 1 on error

File copy.

Definition at line 343 of file file.c.

References se_fclose(), se_fopen(), se_log_assert, se_log_debug(), and SYSTEM_MAXLEN.

Referenced by tools_read_input(), and tools_update().

time_t se_file_lastmodified ( const char *  file)

Get file status.

Parameters:
[in]filefile name
Returns:
time_t last modified

Get file last modified.

Definition at line 248 of file file.c.

References se_fclose(), se_fopen(), and se_log_assert.

Referenced by signconf_read(), and zonelist_read().

const char* se_file_mode2str ( const char *  mode)

Convert file mode to readable string.

Parameters:
[in]modefile mode
Returns:
const char* string

File access. Convert file mode to readable string.

Definition at line 52 of file file.c.

References se_log_assert, and se_strcmp().

Referenced by se_fopen().

FILE* se_fopen ( const char *  file,
const char *  dir,
const char *  mode 
)
const char* se_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 292 of file file.c.

References se_calloc(), se_log_assert, se_strdup(), and SYSTEM_MAXLEN.

Referenced by set_notify_ns().

int se_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 92 of file file.c.

References se_fgetc(), and se_log_assert.

void se_str_trim ( char *  str)

Remove leading and trailing whitespace.

Parameters:
[in]strstring to trim

Remove leading and trailing whitespace.

Definition at line 432 of file file.c.

int se_strcmp ( const char *  s1,
const char *  s2 
)
ssize_t se_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 220 of file file.c.