2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1999 University of Maryland at College Park
4 * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved.
7 * Permission to use, copy, modify, distribute, and sell this software and its
8 * documentation for any purpose is hereby granted without fee, provided that
9 * the above copyright notice appear in all copies and that both that
10 * copyright notice and this permission notice appear in supporting
11 * documentation, and that the name of U.M. not be used in advertising or
12 * publicity pertaining to distribution of the software without specific,
13 * written prior permission. U.M. makes no representations about the
14 * suitability of this software for any purpose. It is provided "as is"
15 * without express or implied warranty.
17 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
19 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
20 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
21 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
22 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
24 * Authors: the Amanda Development Team. Its members are listed in a
25 * file named AUTHORS, in the root directory of this distribution.
28 * $Id: amanda.h,v 1.131 2006/07/25 18:27:56 martinea Exp $
30 * the central header file included by all amanda sources
36 /* use a relative path here to avoid conflicting with Perl's config.h. */
37 #include "../config/config.h"
41 #include <glib/gprintf.h>
46 * Force large file source even if configure guesses wrong.
48 #ifndef _LARGEFILE64_SOURCE
49 #define _LARGEFILE64_SOURCE 1
52 #ifndef _FILE_OFFSET_BITS
53 #define _FILE_OFFSET_BITS 64
56 #ifdef HAVE_SYS_TYPES_H
57 # include <sys/types.h>
60 /* gnulib creates this header locally if the system doesn't provide it,
61 * so it uses a local ("") include */
65 * I would prefer that each Amanda module include only those system headers
66 * that are locally needed, but on most Unixes the system header files are not
67 * protected against multiple inclusion, so this can lead to problems.
69 * Also, some systems put key files in different places, so by including
70 * everything here the rest of the system is isolated from such things.
73 /* from the autoconf documentation */
76 # define NAMLEN(dirent) strlen((dirent)->d_name)
78 # define dirent direct
79 # define NAMLEN(dirent) (dirent)->d_namlen
81 # include <sys/ndir.h>
94 # define plural(String1, String2, Count) \
95 (((Count) == 1) ? (String1) : (String2))
97 # define plural(String1, String2, Count) \
98 (((Count) == 1) ? (String1) : (String2))
99 # define setlocale(Which, Locale)
100 # define textdomain(Domain)
101 # define bindtextdomain(Package, Directory)
102 # define gettext(String) String
103 # define dgettext(Domain, String) String
104 # define dcgettext(Domain, String, Catagory) String
105 # define ngettext(String1, String2, Count) \
106 plural((String1), (String2), (Count))
107 # define dngettext(Domain, String1, String2, Count) \
108 plural((String1), (String2), (Count))
109 # define dcngettext(Domain, String1, String2, Count, Catagory) \
110 plural((String1), (String2), (Count))
112 #define T_(String) String
113 #ifndef SWIG /* TODO: make this go away */
114 #define _(String) dgettext("amanda", (String))
125 #if defined(USE_DB_H)
128 #if defined(USE_DBM_H)
131 #if defined(USE_GDBM_H)
134 #if defined(USE_NDBM_H)
141 #ifdef TIME_WITH_SYS_TIME
142 # include <sys/time.h>
145 # ifdef HAVE_SYS_TIME_H
146 # include <sys/time.h>
168 #ifdef HAVE_STRINGS_H
169 # include <strings.h>
180 #ifdef HAVE_SYS_FILE_H
181 # include <sys/file.h>
184 #ifdef HAVE_SYS_IOCTL_H
185 # include <sys/ioctl.h>
192 #ifdef HAVE_SYS_PARAM_H
193 # include <sys/param.h>
196 #if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SHM_H)
197 # include <sys/ipc.h>
198 # include <sys/shm.h>
200 # ifdef HAVE_SYS_MMAN_H
201 # include <sys/mman.h>
205 #ifdef HAVE_SYS_SELECT_H
206 # include <sys/select.h>
209 #ifdef HAVE_SYS_STAT_H
210 # include <sys/stat.h>
213 #ifdef HAVE_SYS_UIO_H
214 # include <sys/uio.h>
226 #ifdef HAVE_SYS_WAIT_H
227 # include <sys/wait.h>
235 typedef int amwait_t;
237 # define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8)
240 # define WTERMSIG(stat_val) (*(unsigned*)&(stat_val) & 0x7F)
243 # define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0)
246 # ifdef WAIT_USES_UNION
247 typedef union wait amwait_t;
249 # define WEXITSTATUS(stat_val) (((amwait_t*)&(stat_val))->w_retcode)
252 # define WTERMSIG(stat_val) (((amwait_t*)&(stat_val))->w_termsig)
255 # define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0)
258 typedef int amwait_t;
260 # define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8)
263 # define WTERMSIG(stat_val) (*(unsigned*)&(stat_val) & 0x7F)
266 # define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0)
272 # define WIFSIGNALED(stat_val) (WTERMSIG(stat_val) != 0)
279 #ifdef HAVE_NETINET_IN_H
280 # include <netinet/in.h>
289 #include <sys/resource.h>
290 #include <sys/socket.h>
296 #ifndef INET_ADDRSTRLEN
297 #define INET_ADDRSTRLEN 16
300 #if !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC)
301 /* quick'n'dirty hack for NextStep31 */
302 # define sa_flags sv_flags
303 # define sa_handler sv_handler
304 # define sa_mask sv_mask
305 # define sigaction sigvec
306 # define sigemptyset(mask) /* no way to clear pending signals */
310 * Most Unixen declare errno in <errno.h>, some don't. Some multithreaded
311 * systems have errno as a per-thread macro. So, we have to be careful.
318 * Some compilers have int for type of sizeof() some use size_t.
319 * size_t is the one we want...
321 #define SIZEOF(x) (size_t)sizeof(x)
325 * Some older BSD systems don't have these FD_ macros, so if not, provide them.
327 #if !defined(FD_SET) || defined(LINT) || defined(__lint)
329 # define FD_SETSIZE (int)(SIZEOF(fd_set) * CHAR_BIT)
332 # define FD_SET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] |= (int)((1 << ((n) % WORD_BIT))))
335 # define FD_CLR(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] &= (int)(~(1 << ((n) % WORD_BIT))))
338 # define FD_ISSET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] & (1 << ((n) % WORD_BIT)))
341 # define FD_ZERO(p) memset((p), 0, SIZEOF(*(p)))
345 # define FD_COPY(p, q) memcpy((q), (p), SIZEOF(*(p)))
350 * Define MAX_HOSTNAME_LENGTH as the size of arrays to hold hostname's.
352 #undef MAX_HOSTNAME_LENGTH
353 #define MAX_HOSTNAME_LENGTH 1025
356 * If void is broken, substitute char.
362 #define stringize(x) #x
363 #define stringconcat(x, y) x ## y
365 /* amanda #days calculation, with roundoff */
367 #define SECS_PER_DAY (24*60*60)
368 #define days_diff(a, b) (int)(((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY)
370 /* Global constants. */
371 #ifndef AMANDA_SERVICE_NAME
372 #define AMANDA_SERVICE_NAME "amanda"
374 #ifndef KAMANDA_SERVICE_NAME
375 #define KAMANDA_SERVICE_NAME "kamanda"
377 #ifndef SERVICE_SUFFIX
378 #define SERVICE_SUFFIX ""
380 #ifndef AMANDA_SERVICE_DEFAULT
381 #define AMANDA_SERVICE_DEFAULT ((in_port_t)10080)
383 #ifndef KAMANDA_SERVICE_DEFAULT
384 #define KAMANDA_SERVICE_DEFAULT ((in_port_t)10081)
387 #define am_round(v,u) ((((v) + (u) - 1) / (u)) * (u))
388 #define am_floor(v,u) (((v) / (u)) * (u))
390 /* Holding disk block size. Do not even think about changint this! :-) */
391 #define DISK_BLOCK_KB 32
392 #define DISK_BLOCK_BYTES (DISK_BLOCK_KB * 1024)
394 /* Maximum length of tape label, plus one for null-terminator. */
395 #define MAX_TAPE_LABEL_LEN (10240)
396 #define MAX_TAPE_LABEL_BUF (MAX_TAPE_LABEL_LEN+1)
397 #define MAX_TAPE_LABEL_FMT "%10240s"
399 /* Unfortunately, the system-level sockaddr_storage definition can lead to
400 * C aliasing errors (where the optimizer doesn't notice that two operations
401 * affect the same datum). We define our own similar type as a union.
403 typedef union sockaddr_union {
405 struct sockaddr_in sin;
407 struct sockaddr_in6 sin6;
409 #ifdef HAVE_SOCKADDR_STORAGE
410 struct sockaddr_storage ss; /* not used; just here to make the union full-size */
417 void *debug_alloc(const char *file, int line, size_t size);
418 void *debug_newalloc(const char *file, int line, void *old, size_t size);
419 char *debug_stralloc(const char *file, int line, const char *str);
420 char *debug_newstralloc(const char *file, int line,
421 char *oldstr, const char *newstr);
422 char *debug_vstralloc(const char *file, int line, const char *str, ...);
423 char *debug_newvstralloc(const char *file, int line,
424 char *oldstr, const char *str, ...);
425 char *debug_vstrallocf(const char *file, int line, const char *fmt,
426 ...) G_GNUC_PRINTF(3, 4);
427 char *debug_newvstrallocf(const char *file, int line, char *oldstr,
428 const char *fmt, ...) G_GNUC_PRINTF(4, 5);
430 /* Usage: vstrextend(foo, "bar, "baz", NULL). Extends the existing
431 * string, or allocates a brand new one. */
432 char *debug_vstrextend(const char *file, int line, char **oldstr, ...);
434 #define alloc(s) debug_alloc(__FILE__, __LINE__, (s))
435 #define newalloc(p,s) debug_newalloc(__FILE__, __LINE__, (p), (s))
436 #define stralloc(s) debug_stralloc(__FILE__, __LINE__, (s))
437 #define newstralloc(p,s) debug_newstralloc(__FILE__, __LINE__, (p), (s))
438 #define vstralloc(...) debug_vstralloc(__FILE__,__LINE__,__VA_ARGS__)
439 #define newvstralloc(...) debug_newvstralloc(__FILE__,__LINE__,__VA_ARGS__)
440 #define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__)
441 #define newvstrallocf(...) debug_newvstrallocf(__FILE__,__LINE__,__VA_ARGS__)
442 #define vstrextend(...) debug_vstrextend(__FILE__,__LINE__,__VA_ARGS__)
444 #define stralloc2(s1,s2) vstralloc((s1),(s2),NULL)
445 #define newstralloc2(p,s1,s2) newvstralloc((p),(s1),(s2),NULL)
447 #define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__)
449 /*@only@*/ /*@null@*/ char *debug_agets(const char *file, int line, FILE *f);
450 /*@only@*/ /*@null@*/ char *debug_areads(const char *file, int line, int fd);
451 #define agets(f) debug_agets(__FILE__,__LINE__,(f))
452 #define areads(f) debug_areads(__FILE__,__LINE__,(f))
454 /* return a "safe" version of the current environment; pass this to execle */
455 #define safe_env() safe_env_full(NULL)
457 /* like safe_env, but optionally add additional environment variables */
458 char ** safe_env_full(char **add);
460 time_t unctime(char *timestr);
463 * amfree(ptr) -- if allocated, release space and set ptr to NULL.
465 * In general, this should be called instead of just free(), unless
466 * the very next source line sets the pointer to a new value.
469 #define amfree(ptr) do { \
470 if((ptr) != NULL) { \
471 int e__errno = errno; \
475 (void)(ptr); /* Fix value never used warning at end of routines */ \
479 #define strappend(s1,s2) do { \
480 char *t_t_t = (s1) ? stralloc2((s1),(s2)) : stralloc((s2)); \
486 * Return the number of elements in an array.
488 #define am_countof(a) (int)(SIZEOF(a) / SIZEOF((a)[0]))
491 * min/max. Don't do something like
495 * because the increment will be duplicated.
499 #define min(a, b) ((a) < (b) ? (a) : (b))
500 #define max(a, b) ((a) > (b) ? (a) : (b))
503 * Utility bitmask manipulation macros.
505 #define SET(t, f) ((t) |= (f))
506 #define CLR(t, f) ((t) &= ~((unsigned)(f)))
507 #define ISSET(t, f) ((t) & (f))
510 * Utility string macros. All assume a variable holds the current
511 * character and the string pointer points to the next character to
512 * be processed. Typical setup is:
516 * skip_whitespace(s, ch);
519 * If you advance the pointer "by hand" to skip over something, do
525 * Note that ch has the character at the end of the just skipped field.
526 * It is often useful to terminate a string, make a copy, then restore
527 * the input like this:
529 * skip_whitespace(s, ch);
530 * fp = s-1; ## save the start
531 * skip_nonwhitespace(s, ch); ## find the end
532 * p[-1] = '\0'; ## temporary terminate
533 * field = stralloc(fp); ## make a copy
534 * p[-1] = ch; ## restore the input
536 * The scanning macros are:
538 * skip_whitespace (ptr, var)
539 * -- skip whitespace, but stops at a newline
540 * skip_non_whitespace (ptr, var)
541 * -- skip non whitespace
542 * skip_non_whitespace_cs (ptr, var)
543 * -- skip non whitespace, stop at comment
544 * skip_integer (ptr, var)
545 * -- skip an integer field
546 * skip_line (ptr, var)
547 * -- skip just past the next newline
548 * strncmp_const (str, const_str)
549 * -- compare str to const_str, a string constant
550 * strncmp_const_skip (str, const_var, ptr, var)
551 * -- like strncmp_const, but skip the string if a match is
552 * found; this macro only tests for equality, discarding
553 * ordering information.
557 * ptr -- string pointer
558 * var -- current character
560 * These macros copy a non-whitespace field to a new buffer, and should
561 * only be used if dynamic allocation is impossible (fixed size buffers
562 * are asking for trouble):
564 * copy_string (ptr, var, field, len, fldptr)
565 * -- copy a non-whitespace field
566 * copy_string_cs (ptr, var, field, len, fldptr)
567 * -- copy a non-whitespace field, stop at comment
571 * ptr -- string pointer
572 * var -- current character
573 * field -- area to copy to
574 * len -- length of area (needs room for null byte)
575 * fldptr -- work pointer used in move
576 * if NULL on exit, the field was too small for the input
579 #define STR_SIZE 4096 /* a generic string buffer size */
580 #define NUM_STR_SIZE 128 /* a generic number buffer size */
582 #define skip_whitespace(ptr,c) do { \
583 while((c) != '\n' && g_ascii_isspace((int)c)) (c) = *(ptr)++; \
586 #define skip_non_whitespace(ptr,c) do { \
587 while((c) != '\0' && !g_ascii_isspace((int)c)) (c) = *(ptr)++; \
590 #define skip_non_whitespace_cs(ptr,c) do { \
591 while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) (c) = *(ptr)++;\
594 #define skip_non_integer(ptr,c) do { \
595 while((c) != '\0' && !isdigit(c)) (c) = *(ptr)++; \
598 #define skip_integer(ptr,c) do { \
599 if((c) == '+' || (c) == '-') (c) = *(ptr)++; \
600 while(isdigit(c)) (c) = *(ptr)++; \
603 #define skip_quoted_string(ptr, c) do { \
605 while (((c) != '\0') && !((iq == 0) && g_ascii_isspace((int)c))) { \
608 } else if ((c) == '\\') { \
609 if (*ptr) /* not last character */ \
616 #define skip_quoted_line(ptr, c) do { \
618 while((c) && !((iq == 0) && ((c) == '\n'))) { \
627 #define skip_line(ptr,c) do { \
628 while((c) && (c) != '\n') \
634 #define copy_string(ptr,c,f,l,fp) do { \
636 while((c) != '\0' && !g_ascii_isspace((int)c)) { \
637 if((fp) >= (f) + (l) - 1) { \
640 (void)(fp); /* Fix value never used warning at end of routines */ \
650 #define copy_string_cs(ptr,c,f,l,fp) do { \
652 while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) { \
653 if((fp) >= (f) + (l) - 1) { \
664 #define is_dot_or_dotdot(s) \
667 || ((s)[1] == '.' && (s)[2] == '\0')))
669 #define strncmp_const(str, cnst) \
670 strncmp((str), (cnst), sizeof((cnst))-1)
672 /* (have to roll this up in an expression, so it can be used in if()) */
673 #define strncmp_const_skip(str, cnst, ptr, var) \
674 ((strncmp((str), (cnst), sizeof((cnst))-1) == 0)? \
675 ((ptr)+=sizeof((cnst))-1, (var)=(ptr)[-1], 0) \
678 /* from old bsd-security.c */
680 extern int check_security(sockaddr_union *, char *, unsigned long, char **);
683 * Handle functions which are not always declared on all systems. This
684 * stops gcc -Wall and lint from complaining.
687 /* AIX #defines accept, and provides a prototype for the alternate name */
688 #if !defined(HAVE_ACCEPT_DECL) && !defined(accept)
689 extern int accept(int s, struct sockaddr *addr, socklen_t_equiv *addrlen);
692 #ifndef HAVE_ATOF_DECL
693 extern double atof(const char *ptr);
697 # define bcopy(from,to,n) ((void)memmove((to), (from), (n)))
699 # ifndef HAVE_BCOPY_DECL
700 extern void bcopy(const void *s1, void *s2, size_t n);
704 #ifndef HAVE_BIND_DECL
705 extern int bind(int s, const struct sockaddr *name, socklen_t_equiv namelen);
709 #define bzero(s,n) ((void)memset((s),0,(n)))
711 # ifndef HAVE_BZERO_DECL
712 extern void bzero(void *s, size_t n);
716 #ifndef HAVE_CLOSELOG_DECL
717 extern void closelog(void);
720 #ifndef HAVE_CONNECT_DECL
721 extern int connect(int s, struct sockaddr *name, socklen_t_equiv namelen);
724 #ifndef HAVE_FCLOSE_DECL
725 extern int fclose(FILE *stream);
728 #ifndef HAVE_FFLUSH_DECL
729 extern int fflush(FILE *stream);
732 #ifndef HAVE_FPRINTF_DECL
733 extern int fprintf(FILE *stream, const char *format, ...);
736 #ifndef HAVE_FPUTC_DECL
737 extern int fputc(int c, FILE *stream);
740 #ifndef HAVE_FPUTS_DECL
741 extern int fputs(const char *s, FILE *stream);
744 #ifndef HAVE_FREAD_DECL
745 extern size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
748 #ifndef HAVE_FSEEK_DECL
749 extern int fseek(FILE *stream, long offset, int ptrname);
752 #ifndef HAVE_FWRITE_DECL
753 extern size_t fwrite(const void *ptr, size_t size, size_t nitems,
757 #ifndef HAVE_GETHOSTNAME_DECL
758 extern int gethostname(char *name, int namelen);
761 #ifndef HAVE_GETOPT_DECL
763 extern int getopt(int argc, char * const *argv, const char *optstring);
766 /* AIX #defines getpeername, and provides a prototype for the alternate name */
767 #if !defined(HAVE_GETPEERNAME_DECL) && !defined(getpeername)
768 extern int getpeername(int s, struct sockaddr *name, socklen_t_equiv *namelen);
771 /* AIX #defines getsockname, and provides a prototype for the alternate name */
772 #if !defined(HAVE_GETSOCKNAME_DECL) && !defined(getsockname)
773 extern int getsockname(int s, struct sockaddr *name, socklen_t_equiv *namelen);
776 #ifndef HAVE_GETSOCKOPT_DECL
777 extern int getsockopt(int s, int level, int optname, char *optval,
778 socklen_t_equiv *optlen);
781 #ifndef HAVE_INITGROUPS
782 # define initgroups(name,basegid) 0
784 # ifndef HAVE_INITGROUPS_DECL
785 extern int initgroups(const char *name, gid_t basegid);
789 #ifndef HAVE_IOCTL_DECL
790 extern int ioctl(int fildes, int request, ...);
794 #ifndef HAVE_ISNORMAL
795 #define isnormal(f) (((f) < 0.0) || ((f) > 0.0))
799 #ifndef HAVE_LISTEN_DECL
800 extern int listen(int s, int backlog);
803 #ifndef HAVE_LSTAT_DECL
804 extern int lstat(const char *path, struct stat *buf);
807 #ifndef HAVE_MALLOC_DECL
808 extern void *malloc (size_t size);
811 #ifndef HAVE_MEMMOVE_DECL
813 extern void *memmove(void *to, const void *from, size_t n);
815 extern char *memmove(char *to, /*const*/ char *from, size_t n);
819 #ifndef HAVE_MEMSET_DECL
820 extern void *memset(void *s, int c, size_t n);
823 #ifndef HAVE_MKTEMP_DECL
824 extern char *mktemp(char *template);
827 #ifndef HAVE_MKSTEMP_DECL
828 extern int mkstemp(char *template);
831 #ifndef HAVE_MKTIME_DECL
832 extern time_t mktime(struct tm *timeptr);
835 #ifndef HAVE_OPENLOG_DECL
837 extern void openlog(const char *ident, int logopt, int facility);
839 extern void openlog(const char *ident, int logopt);
843 #ifndef HAVE_PCLOSE_DECL
844 extern int pclose(FILE *stream);
847 #ifndef HAVE_PERROR_DECL
848 extern void perror(const char *s);
851 #ifndef HAVE_PRINTF_DECL
852 extern int printf(const char *format, ...);
855 #ifndef HAVE_PUTS_DECL
856 extern int puts(const char *s);
859 #ifndef HAVE_REALLOC_DECL
860 extern void *realloc(void *ptr, size_t size);
863 /* AIX #defines recvfrom, and provides a prototype for the alternate name */
864 #if !defined(HAVE_RECVFROM_DECL) && !defined(recvfrom)
865 extern int recvfrom(int s, char *buf, int len, int flags,
866 struct sockaddr *from, socklen_t_equiv *fromlen);
869 #ifndef HAVE_REMOVE_DECL
870 extern int remove(const char *path);
873 #ifndef HAVE_RENAME_DECL
874 extern int rename(const char *old, const char *new);
877 #ifndef HAVE_REWIND_DECL
878 extern void rewind(FILE *stream);
881 #ifndef HAVE_RUSEROK_DECL
882 extern int ruserok(const char *rhost, int suser,
883 const char *ruser, const char *luser);
886 #ifndef HAVE_SELECT_DECL
887 extern int select(int nfds,
888 SELECT_ARG_TYPE *readfds,
889 SELECT_ARG_TYPE *writefds,
890 SELECT_ARG_TYPE *exceptfds,
891 struct timeval *timeout);
894 #ifndef HAVE_SENDTO_DECL
895 extern int sendto(int s, const char *msg, int len, int flags,
896 const struct sockaddr *to, int tolen);
899 #ifdef HAVE_SETRESGID
900 #define setegid(x) setresgid((gid_t)-1,(x),(gid_t)-1)
901 #ifndef HAVE_SETRESGID_DECL
902 extern int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
905 #ifndef HAVE_SETEGID_DECL
906 extern int setegid(gid_t egid);
910 #ifdef HAVE_SETRESUID
911 #define seteuid(x) setresuid((uid_t)-1,(x),(uid_t)-1)
912 #ifndef HAVE_SETRESUID_DECL
913 extern int setresuid(uid_t ruid, uid_t euid, uid_t suid);
916 #ifndef HAVE_SETEUID_DECL
917 extern int seteuid(uid_t euid);
921 #ifndef HAVE_SETPGID_DECL
923 extern int setpgid(pid_t pid, pid_t pgid);
927 #ifndef HAVE_SETPGRP_DECL
929 extern pid_t setpgrp(void);
931 extern pid_t setpgrp(pid_t pgrp, pid_t pid);
935 #ifndef HAVE_SETSOCKOPT_DECL
936 extern int setsockopt(int s, int level, int optname,
937 const char *optval, int optlen);
941 #ifndef HAVE_SHMAT_DECL
942 extern void *shmat(int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg);
945 #ifndef HAVE_SHMCTL_DECL
946 extern int shmctl(int shmid, int cmd, struct shmid_ds *buf);
949 #ifndef HAVE_SHMDT_DECL
950 extern int shmdt(SHM_ARG_TYPE *shaddr);
953 #ifndef HAVE_SHMGET_DECL
954 extern int shmget(key_t key, size_t size, int shmflg);
958 #ifndef HAVE_SNPRINTF_DECL
960 int snprintf(char *buf, size_t len, const char *format,...)
963 #ifndef HAVE_VSNPRINTF_DECL
965 int vsnprintf(char *buf, size_t len, const char *format, va_list ap);
968 #ifndef HAVE_SOCKET_DECL
969 extern int socket(int domain, int type, int protocol);
972 #ifndef HAVE_SOCKETPAIR_DECL
973 extern int socketpair(int domain, int type, int protocol, int sv[2]);
976 #ifndef HAVE_SSCANF_DECL
977 extern int sscanf(const char *s, const char *format, ...);
980 #ifndef HAVE_STRCASECMP_DECL
981 extern int strcasecmp(const char *s1, const char *s2);
984 #ifndef HAVE_STRERROR_DECL
985 extern char *strerror(int errnum);
988 #ifndef HAVE_STRFTIME_DECL
989 extern size_t strftime(char *s, size_t maxsize, const char *format,
990 const struct tm *timeptr);
993 #ifndef HAVE_STRNCASECMP_DECL
994 extern int strncasecmp(const char *s1, const char *s2, int n);
997 #ifndef HAVE_SYSLOG_DECL
998 extern void syslog(int priority, const char *logstring, ...)
1002 #ifndef HAVE_SYSTEM_DECL
1003 extern int system(const char *string);
1006 #ifndef HAVE_TIME_DECL
1007 extern time_t time(time_t *tloc);
1010 #ifndef HAVE_TOLOWER_DECL
1011 extern int tolower(int c);
1014 #ifndef HAVE_TOUPPER_DECL
1015 extern int toupper(int c);
1018 #ifndef HAVE_UNGETC_DECL
1019 extern int ungetc(int c, FILE *stream);
1022 #ifndef HAVE_VFPRINTF_DECL
1023 #include "arglist.h"
1024 extern int vfprintf(FILE *stream, const char *format, va_list ap);
1027 #ifndef HAVE_VPRINTF_DECL
1028 #include "arglist.h"
1029 extern int vprintf(const char *format, va_list ap);
1032 /* these system headers are added by gnulib if they
1035 #include "arpa/inet.h"
1037 /* gnulib-only includes */
1038 #include "safe-read.h"
1039 #include "full-read.h"
1040 #include "full-write.h"
1042 #if !defined(S_ISCHR) && defined(_S_IFCHR) && defined(_S_IFMT)
1043 #define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR)
1046 #if !defined(S_ISREG) && defined(_S_IFREG) && defined(_S_IFMT)
1047 #define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG)
1050 #ifndef HAVE_WAITPID
1052 #define waitpid(pid,status,options) wait4(pid,status,options,0)
1054 extern pid_t waitpid(pid_t pid, amwait_t *stat_loc, int options);
1058 #ifndef HAVE_WRITEV_DECL
1059 extern ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
1062 #ifndef STDIN_FILENO
1063 #define STDIN_FILENO 0
1066 #ifndef STDOUT_FILENO
1067 #define STDOUT_FILENO 1
1070 #ifndef STDERR_FILENO
1071 #define STDERR_FILENO 2
1074 /* S_ISDIR is not defined on Nextstep */
1076 #if defined(_S_IFMT) && defined(_S_IFDIR)
1077 #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
1079 #error Don t know how to define S_ISDIR
1083 #if SIZEOF_SIZE_T == SIZEOF_INT
1084 # define SIZE_T_ATOI (size_t)atoi
1086 # define SIZE_MAX G_MAXUINT
1089 # define SIZE_T_ATOI (size_t)atol
1091 # define SIZE_MAX ULONG_MAX
1095 #if SIZEOF_SSIZE_T == SIZEOF_INT
1096 # define SSIZE_T_ATOI (ssize_t)atoi
1098 # define SSIZE_MAX INT_MAX
1101 # define SSIZE_MIN INT_MIN
1104 # define SSIZE_T_ATOI (ssize_t)atol
1106 # define SSIZE_MAX LONG_MAX
1109 # define SSIZE_MIN LONG_MIN
1113 #if SIZEOF_TIME_T == SIZEOF_INT
1114 # define TIME_T_ATOI (time_t)atoi
1116 # define TIME_MAX G_MAXUINT
1119 # define TIME_T_ATOI (time_t)atol
1121 # define TIME_MAX ULONG_MAX
1125 #if SIZEOF_OFF_T > SIZEOF_LONG
1127 # define OFF_T_ATOI (off_t)atoll
1129 # define OFF_T_ATOI (off_t)atol
1131 # ifdef HAVE_STRTOLL
1132 # define OFF_T_STRTOL (off_t)strtoll
1134 # define OFF_T_STRTOL (off_t)strtol
1137 # if SIZEOF_OFF_T == SIZEOF_LONG
1138 # define OFF_T_ATOI (off_t)atol
1139 # define OFF_T_STRTOL (off_t)strtol
1141 # define OFF_T_ATOI (off_t)atoi
1142 # define OFF_T_STRTOL (off_t)strtol
1147 #define BIND_CYCLE_RETRIES 120 /* Total of 30 minutes */
1149 #define MAX_DUMPERS 63
1152 #define NI_MAXHOST 1025
1156 KENCRYPT_NONE, /* krb5 encryption not enabled */
1157 KENCRYPT_WILL_DO, /* krb5 encryption will be enabled once amanda
1158 protocol stream is closed */
1159 KENCRYPT_YES /* krb5 encryption enabled on all stream */
1162 #define DUMP_LEVELS 400
1164 /* Constants to define the number of pre-opened pipes between amandad and
1167 /* If you change these (don't!), change them in perl/Amanda/Constants.pm, too */
1168 #define DATA_FD_COUNT 3 /* number of general-use pipes */
1169 #define DATA_FD_OFFSET 50
1171 #endif /* !AMANDA_H */