OpenDNSSEC-signer  1.4.7
file.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 NLNet Labs. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
14  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
17  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
19  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
20  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
21  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
22  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
23  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24  *
25  */
26 
32 #ifndef SHARED_FILE_H
33 #define SHARED_FILE_H
34 
35 #include "config.h"
36 #include "shared/status.h"
37 
38 #include <stdio.h>
39 #include <stdlib.h>
40 #include <time.h>
41 
42 #ifdef HAVE_SYS_TYPES_H
43 # include <sys/types.h>
44 #endif
45 #ifdef HAVE_UNISTD_H
46 # include <unistd.h>
47 #endif
48 
49 #define SYSTEM_MAXLEN 1024
50 
57 const char* ods_file_mode2str(const char* mode);
58 
66 int ods_fgetc(FILE* fd, unsigned int* line_nr);
67 
75 int ods_skip_whitespace(FILE* fd, unsigned int* line_nr);
76 
86 char* ods_build_path(const char* file, const char* suffix, int dir,
87  int no_slash);
88 
97 FILE* ods_fopen(const char* file, const char* dir, const char* mode);
98 
104 void ods_fclose(FILE* fd);
105 
113 ssize_t ods_writen(int fd, const void* vptr, size_t n);
114 
121 time_t ods_file_lastmodified(const char* file);
122 
130 int ods_strcmp(const char* s1, const char* s2);
131 
139 int ods_strlowercmp(const char* s1, const char* s2);
140 
149 const char* ods_replace(const char *str, const char *oldstr,
150  const char *newstr);
151 
158 char* ods_dir_name(const char* file);
159 
169 ods_status ods_file_copy(const char* file1, const char* file2, long startpos,
170  int append);
171 
180 void ods_chown(const char* file, uid_t uid, gid_t gid, int getdir);
181 
182 
188 void ods_str_trim(char* str);
189 
196 void ods_str_list_add(char*** list, char* str);
197 
198 #endif /* SHARED_FILE_H */
ods_status ods_file_copy(const char *file1, const char *file2, long startpos, int append)
Definition: file.c:431
int ods_skip_whitespace(FILE *fd, unsigned int *line_nr)
Definition: file.c:103
time_t ods_file_lastmodified(const char *file)
Definition: file.c:293
ssize_t ods_writen(int fd, const void *vptr, size_t n)
Definition: file.c:265
FILE * ods_fopen(const char *file, const char *dir, const char *mode)
Definition: file.c:190
int ods_strlowercmp(const char *s1, const char *s2)
Definition: file.c:342
enum ods_enum_status ods_status
Definition: status.h:90
void ods_chown(const char *file, uid_t uid, gid_t gid, int getdir)
Definition: file.c:518
int ods_strcmp(const char *s1, const char *s2)
Definition: file.c:320
void ods_str_trim(char *str)
Definition: file.c:554
void ods_str_list_add(char ***list, char *str)
Definition: file.c:593
char * ods_dir_name(const char *file)
Definition: file.c:487
const char * ods_file_mode2str(const char *mode)
Definition: file.c:57
char * ods_build_path(const char *file, const char *suffix, int dir, int no_slash)
Definition: file.c:125
void ods_fclose(FILE *fd)
Definition: file.c:250
int ods_fgetc(FILE *fd, unsigned int *line_nr)
Definition: file.c:79
const char * ods_replace(const char *str, const char *oldstr, const char *newstr)
Definition: file.c:374