OpenDNSSEC-signer 1.3.0rc3
|
00001 /* 00002 * $Id: file.h 5227 2011-06-12 08:51:24Z jakob $ 00003 * 00004 * Copyright (c) 2009 NLNet Labs. All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions 00008 * are met: 00009 * 1. Redistributions of source code must retain the above copyright 00010 * notice, this list of conditions and the following disclaimer. 00011 * 2. Redistributions in binary form must reproduce the above copyright 00012 * notice, this list of conditions and the following disclaimer in the 00013 * documentation and/or other materials provided with the distribution. 00014 * 00015 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 00016 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00017 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 00018 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 00019 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00020 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 00021 * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 00022 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER 00023 * IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 00024 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN 00025 * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00026 * 00027 */ 00028 00034 #ifndef SHARED_FILE_H 00035 #define SHARED_FILE_H 00036 00037 #include "config.h" 00038 00039 #include <stdio.h> 00040 #include <stdlib.h> 00041 #include <time.h> 00042 00043 #ifdef HAVE_SYS_TYPES_H 00044 # include <sys/types.h> 00045 #endif 00046 #ifdef HAVE_UNISTD_H 00047 # include <unistd.h> 00048 #endif 00049 00050 #define SYSTEM_MAXLEN 1024 00051 00058 const char* ods_file_mode2str(const char* mode); 00059 00067 int ods_fgetc(FILE* fd, unsigned int* line_nr); 00068 00076 int ods_skip_whitespace(FILE* fd, unsigned int* line_nr); 00077 00086 char* ods_build_path(const char* file, const char* suffix, int dir); 00087 00096 FILE* ods_fopen(const char* file, const char* dir, const char* mode); 00097 00103 void ods_fclose(FILE* fd); 00104 00112 ssize_t ods_writen(int fd, const void* vptr, size_t n); 00113 00120 time_t ods_file_lastmodified(const char* file); 00121 00129 int ods_strcmp(const char* s1, const char* s2); 00130 00139 const char* ods_replace(const char *str, const char *oldstr, 00140 const char *newstr); 00141 00148 char* ods_dir_name(const char* file); 00149 00157 int ods_file_copy(const char* file1, const char* file2); 00158 00167 void ods_chown(const char* file, uid_t uid, gid_t gid, int getdir); 00168 00169 00175 void ods_str_trim(char* str); 00176 00177 #endif /* SHARED_FILE_H */