2 * Copyright (C) 2005 Roy Keene
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version 2
7 * of the License, or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 * Planning Systems Inc
22 * backuppcd-bugs@psislidell.com
30 #define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl(x >> 32))
39 #define ntohll(x) ((((uint64_t)ntohl(x)) << 32) + ntohl(x >> 32))
53 #ifdef HAVE_INTTYPES_H
71 #ifdef HAVE_SYS_STAT_H
74 #ifdef HAVE_SYS_TYPES_H
75 #include <sys/types.h>
89 #ifdef HAVE_NETINET_IN_H
90 #include <netinet/in.h>
95 #ifdef HAVE_SYS_SOCKET_H
96 #include <sys/socket.h>
98 #ifdef HAVE_SYS_STATFS_H
99 #include <sys/statfs.h>
101 #ifdef HAVE_SYS_VFS_H
105 #ifdef HAVE_SYS_RESOURCE_H
106 #include <sys/resource.h>
108 #ifdef TIME_WITH_SYS_TIME
109 #include <sys/time.h>
112 #ifdef HAVE_SYS_TIME_H
113 #include <sys/time.h>
119 #ifndef HAVE_SOCKLEN_T
120 #ifdef NEED_SOCKLEN_T
121 typedef int socklen_t;
130 #ifndef HAVE_GETHOSTNAME
131 #include "gethostname.h"
136 * These constants are used to determine the filesystem type from statfs().
137 * Only used under Linux as other statfs() implementations return ftype == 0.
139 #ifndef NFS_SUPER_MAGIC
140 #define NFS_SUPER_MAGIC 0x6969
142 #ifndef PROC_SUPER_MAGIC
143 #define PROC_SUPER_MAGIC 0x9fa0
145 #ifndef DEVFS_SUPER_MAGIC
146 #define DEVFS_SUPER_MAGIC 0x1373
148 #ifndef ISOFS_SUPER_MAGIC
149 #define ISOFS_SUPER_MAGIC 0x9660
151 #ifndef NCP_SUPER_MAGIC
152 #define NCP_SUPER_MAGIC 0x564c
154 #ifndef SMB_SUPER_MAGIC
155 #define SMB_SUPER_MAGIC 0x517B
158 #define TMPFS_MAGIC 0x01021994
165 #define PRINT_LINE fprintf(stderr, "%lu:%s:%i:%s(): ", (unsigned long) time(NULL), __FILE__, __LINE__, __func__);
166 #define PRINTERR_D(x...) { PRINT_LINE; fprintf(stderr, x); fprintf(stderr, "\n"); }
167 #define PERROR(x) { PRINT_LINE; perror(x); }
168 #define DPERROR(x) PERROR(x)
169 #define DPRINTF(x...) { PRINT_LINE; fprintf(stderr, x); fprintf(stderr, "\n"); }
171 #define PRINT_LINE /**/
172 #define PRINTERR_D(x...) /**/
173 #define PERROR(x) perror(x);
174 #define DPERROR(x) /**/
176 #define CHECKPOINT PRINTERR_D("*** CHECKPOINT REACHED ***")
177 #define SPOTVAR_LLX(x) PRINTERR_D(#x " = %llx", (unsigned long long) x)
178 #define SPOTVAR_LLU(x) PRINTERR_D(#x " = %llu", (unsigned long long) x)
179 #define SPOTVAR_LU(x) PRINTERR_D(#x " = %lu", (unsigned long) x)
180 #define SPOTVAR_D(x) PRINTERR_D(#x " = %lf", x)
181 #define SPOTVAR_X(x) PRINTERR_D(#x " = 0x%x", (unsigned int) x)
182 #define SPOTVAR_I(x) PRINTERR_D(#x " = %i", (int) x)
183 #define SPOTVAR_P(x) PRINTERR_D(#x " = %p", x)
184 #define SPOTVAR_S(x) PRINTERR_D(#x " = \"%s\"", x)
185 #define PRINTERR(x...) { PRINT_LINE; fprintf(stderr, x); fprintf(stderr, "\n"); fflush(stderr); }
186 #define LOG(x...) { PRINT_LINE; fprintf(stderr, "LOG: " x); fprintf(stderr, "\n"); }