OpenDNSSEC-signer  1.3.16
file.h
Go to the documentation of this file.
1 /*
2  * $Id: file.h 6244 2012-04-03 13:56:27Z 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 
142 const char* ods_replace(const char *str, const char *oldstr,
143  const char *newstr);
144 
151 char* ods_dir_name(const char* file);
152 
160 ods_status ods_file_copy(const char* file1, const char* file2);
161 
170 void ods_chown(const char* file, uid_t uid, gid_t gid, int getdir);
171 
172 
178 void ods_str_trim(char* str);
179 
180 #endif /* SHARED_FILE_H */
char * ods_dir_name(const char *file)
Definition: file.c:439
int ods_skip_whitespace(FILE *fd, unsigned int *line_nr)
Definition: file.c:106
enum ods_enum_status ods_status
Definition: status.h:64
time_t ods_file_lastmodified(const char *file)
Definition: file.c:287
int ods_strcmp(const char *s1, const char *s2)
Definition: file.c:317
int ods_fgetc(FILE *fd, unsigned int *line_nr)
Definition: file.c:79
FILE * ods_fopen(const char *file, const char *dir, const char *mode)
Definition: file.c:188
void ods_str_trim(char *str)
Definition: file.c:506
ssize_t ods_writen(int fd, const void *vptr, size_t n)
Definition: file.c:259
char * ods_build_path(const char *file, const char *suffix, int dir, int no_slash)
Definition: file.c:128
void ods_chown(const char *file, uid_t uid, gid_t gid, int getdir)
Definition: file.c:470
void ods_fclose(FILE *fd)
Definition: file.c:245
const char * ods_replace(const char *str, const char *oldstr, const char *newstr)
Definition: file.c:339
ods_status ods_file_copy(const char *file1, const char *file2)
Definition: file.c:396
const char * ods_file_mode2str(const char *mode)
Definition: file.c:57