OpenDNSSEC-signer  1.4.1
file.h
Go to the documentation of this file.
1 /*
2  * $Id: file.h 6501 2012-08-06 10:52:03Z matthijs $
3  *
4  * Copyright (c) 2009 NLNet Labs. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  *
15  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18  * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
19  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
21  * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
23  * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
24  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
25  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  *
27  */
28 
34 #ifndef SHARED_FILE_H
35 #define SHARED_FILE_H
36 
37 #include "config.h"
38 #include "shared/status.h"
39 
40 #include <stdio.h>
41 #include <stdlib.h>
42 #include <time.h>
43 
44 #ifdef HAVE_SYS_TYPES_H
45 # include <sys/types.h>
46 #endif
47 #ifdef HAVE_UNISTD_H
48 # include <unistd.h>
49 #endif
50 
51 #define SYSTEM_MAXLEN 1024
52 
59 const char* ods_file_mode2str(const char* mode);
60 
68 int ods_fgetc(FILE* fd, unsigned int* line_nr);
69 
77 int ods_skip_whitespace(FILE* fd, unsigned int* line_nr);
78 
88 char* ods_build_path(const char* file, const char* suffix, int dir,
89  int no_slash);
90 
99 FILE* ods_fopen(const char* file, const char* dir, const char* mode);
100 
106 void ods_fclose(FILE* fd);
107 
115 ssize_t ods_writen(int fd, const void* vptr, size_t n);
116 
123 time_t ods_file_lastmodified(const char* file);
124 
132 int ods_strcmp(const char* s1, const char* s2);
133 
141 int ods_strlowercmp(const char* s1, const char* s2);
142 
151 const char* ods_replace(const char *str, const char *oldstr,
152  const char *newstr);
153 
160 char* ods_dir_name(const char* file);
161 
169 ods_status ods_file_copy(const char* file1, const char* file2);
170 
179 void ods_chown(const char* file, uid_t uid, gid_t gid, int getdir);
180 
181 
187 void ods_str_trim(char* str);
188 
195 void ods_str_list_add(char*** list, char* str);
196 
197 #endif /* SHARED_FILE_H */