2 * Amanda, The Advanced Maryland Automatic Network Disk Archiver
3 * Copyright (c) 1991-1999 University of Maryland at College Park
6 * Permission to use, copy, modify, distribute, and sell this software and its
7 * documentation for any purpose is hereby granted without fee, provided that
8 * the above copyright notice appear in all copies and that both that
9 * copyright notice and this permission notice appear in supporting
10 * documentation, and that the name of U.M. not be used in advertising or
11 * publicity pertaining to distribution of the software without specific,
12 * written prior permission. U.M. makes no representations about the
13 * suitability of this software for any purpose. It is provided "as is"
14 * without express or implied warranty.
16 * U.M. DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL U.M.
18 * BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
19 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION
20 * OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
21 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
23 * Authors: the Amanda Development Team. Its members are listed in a
24 * file named AUTHORS, in the root directory of this distribution.
27 * $Id: amanda.h,v 1.131 2006/07/25 18:27:56 martinea Exp $
29 * the central header file included by all amanda sources
35 /* use a relative path here to avoid conflicting with Perl's config.h. */
36 #include "../config/config.h"
40 #include <glib/gprintf.h>
45 * Force large file source even if configure guesses wrong.
47 #ifndef _LARGEFILE64_SOURCE
48 #define _LARGEFILE64_SOURCE 1
51 #ifndef _FILE_OFFSET_BITS
52 #define _FILE_OFFSET_BITS 64
55 #ifdef HAVE_SYS_TYPES_H
56 # include <sys/types.h>
59 /* gnulib creates this header locally if the system doesn't provide it,
60 * so it uses a local ("") include */
64 * I would prefer that each Amanda module include only those system headers
65 * that are locally needed, but on most Unixes the system header files are not
66 * protected against multiple inclusion, so this can lead to problems.
68 * Also, some systems put key files in different places, so by including
69 * everything here the rest of the system is isolated from such things.
72 /* from the autoconf documentation */
75 # define NAMLEN(dirent) strlen((dirent)->d_name)
77 # define dirent direct
78 # define NAMLEN(dirent) (dirent)->d_namlen
80 # include <sys/ndir.h>
93 # define plural(String1, String2, Count) \
94 (((Count) == 1) ? (String1) : (String2))
96 # define plural(String1, String2, Count) \
97 (((Count) == 1) ? (String1) : (String2))
98 # define setlocale(Which, Locale)
99 # define textdomain(Domain)
100 # define bindtextdomain(Package, Directory)
101 # define gettext(String) String
102 # define dgettext(Domain, String) String
103 # define dcgettext(Domain, String, Catagory) String
104 # define ngettext(String1, String2, Count) \
105 plural((String1), (String2), (Count))
106 # define dngettext(Domain, String1, String2, Count) \
107 plural((String1), (String2), (Count))
108 # define dcngettext(Domain, String1, String2, Count, Catagory) \
109 plural((String1), (String2), (Count))
111 #define T_(String) String
112 #ifndef SWIG /* TODO: make this go away */
113 #define _(String) dgettext("amanda", (String))
124 #if defined(USE_DB_H)
127 #if defined(USE_DBM_H)
130 #if defined(USE_GDBM_H)
133 #if defined(USE_NDBM_H)
140 #ifdef TIME_WITH_SYS_TIME
141 # include <sys/time.h>
144 # ifdef HAVE_SYS_TIME_H
145 # include <sys/time.h>
167 #ifdef HAVE_STRINGS_H
168 # include <strings.h>
179 #ifdef HAVE_SYS_FILE_H
180 # include <sys/file.h>
183 #ifdef HAVE_SYS_IOCTL_H
184 # include <sys/ioctl.h>
191 #ifdef HAVE_SYS_PARAM_H
192 # include <sys/param.h>
195 #if defined(HAVE_SYS_IPC_H) && defined(HAVE_SYS_SHM_H)
196 # include <sys/ipc.h>
197 # include <sys/shm.h>
199 # ifdef HAVE_SYS_MMAN_H
200 # include <sys/mman.h>
204 #ifdef HAVE_SYS_SELECT_H
205 # include <sys/select.h>
208 #ifdef HAVE_SYS_STAT_H
209 # include <sys/stat.h>
212 #ifdef HAVE_SYS_UIO_H
213 # include <sys/uio.h>
225 #ifdef HAVE_SYS_WAIT_H
226 # include <sys/wait.h>
234 typedef int amwait_t;
236 # define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8)
239 # define WTERMSIG(stat_val) (*(unsigned*)&(stat_val) & 0x7F)
242 # define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0)
245 # ifdef WAIT_USES_UNION
246 typedef union wait amwait_t;
248 # define WEXITSTATUS(stat_val) (((amwait_t*)&(stat_val))->w_retcode)
251 # define WTERMSIG(stat_val) (((amwait_t*)&(stat_val))->w_termsig)
254 # define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0)
257 typedef int amwait_t;
259 # define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8)
262 # define WTERMSIG(stat_val) (*(unsigned*)&(stat_val) & 0x7F)
265 # define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0)
271 # define WIFSIGNALED(stat_val) (WTERMSIG(stat_val) != 0)
278 #ifdef HAVE_NETINET_IN_H
279 # include <netinet/in.h>
288 #include <sys/resource.h>
289 #include <sys/socket.h>
295 #ifndef INET_ADDRSTRLEN
296 #define INET_ADDRSTRLEN 16
299 #if !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC)
300 /* quick'n'dirty hack for NextStep31 */
301 # define sa_flags sv_flags
302 # define sa_handler sv_handler
303 # define sa_mask sv_mask
304 # define sigaction sigvec
305 # define sigemptyset(mask) /* no way to clear pending signals */
309 * Most Unixen declare errno in <errno.h>, some don't. Some multithreaded
310 * systems have errno as a per-thread macro. So, we have to be careful.
317 * Some compilers have int for type of sizeof() some use size_t.
318 * size_t is the one we want...
320 #define SIZEOF(x) (size_t)sizeof(x)
324 * Some older BSD systems don't have these FD_ macros, so if not, provide them.
326 #if !defined(FD_SET) || defined(LINT) || defined(__lint)
328 # define FD_SETSIZE (int)(SIZEOF(fd_set) * CHAR_BIT)
331 # define FD_SET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] |= (int)((1 << ((n) % WORD_BIT))))
334 # define FD_CLR(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] &= (int)(~(1 << ((n) % WORD_BIT))))
337 # define FD_ISSET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] & (1 << ((n) % WORD_BIT)))
340 # define FD_ZERO(p) memset((p), 0, SIZEOF(*(p)))
344 # define FD_COPY(p, q) memcpy((q), (p), SIZEOF(*(p)))
349 * Define MAX_HOSTNAME_LENGTH as the size of arrays to hold hostname's.
351 #undef MAX_HOSTNAME_LENGTH
352 #define MAX_HOSTNAME_LENGTH 1025
355 * If void is broken, substitute char.
361 #define stringize(x) #x
362 #define stringconcat(x, y) x ## y
364 /* amanda #days calculation, with roundoff */
366 #define SECS_PER_DAY (24*60*60)
367 #define days_diff(a, b) (int)(((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY)
369 /* Global constants. */
370 #ifndef AMANDA_SERVICE_NAME
371 #define AMANDA_SERVICE_NAME "amanda"
373 #ifndef KAMANDA_SERVICE_NAME
374 #define KAMANDA_SERVICE_NAME "kamanda"
376 #ifndef SERVICE_SUFFIX
377 #define SERVICE_SUFFIX ""
379 #ifndef AMANDA_SERVICE_DEFAULT
380 #define AMANDA_SERVICE_DEFAULT ((in_port_t)10080)
382 #ifndef KAMANDA_SERVICE_DEFAULT
383 #define KAMANDA_SERVICE_DEFAULT ((in_port_t)10081)
386 #define am_round(v,u) ((((v) + (u) - 1) / (u)) * (u))
387 #define am_floor(v,u) (((v) / (u)) * (u))
389 /* Holding disk block size. Do not even think about changint this! :-) */
390 #define DISK_BLOCK_KB 32
391 #define DISK_BLOCK_BYTES (DISK_BLOCK_KB * 1024)
393 /* Maximum length of tape label, plus one for null-terminator. */
394 #define MAX_TAPE_LABEL_LEN (10240)
395 #define MAX_TAPE_LABEL_BUF (MAX_TAPE_LABEL_LEN+1)
396 #define MAX_TAPE_LABEL_FMT "%10240s"
398 /* Unfortunately, the system-level sockaddr_storage definition can lead to
399 * C aliasing errors (where the optimizer doesn't notice that two operations
400 * affect the same datum). We define our own similar type as a union.
402 typedef union sockaddr_union {
404 struct sockaddr_in sin;
406 struct sockaddr_in6 sin6;
408 #ifdef HAVE_SOCKADDR_STORAGE
409 struct sockaddr_storage ss; /* not used; just here to make the union full-size */
416 void *debug_alloc(const char *file, int line, size_t size);
417 void *debug_newalloc(const char *file, int line, void *old, size_t size);
418 char *debug_stralloc(const char *file, int line, const char *str);
419 char *debug_newstralloc(const char *file, int line,
420 char *oldstr, const char *newstr);
421 char *debug_vstralloc(const char *file, int line, const char *str, ...);
422 char *debug_newvstralloc(const char *file, int line,
423 char *oldstr, const char *str, ...);
424 char *debug_vstrallocf(const char *file, int line, const char *fmt,
425 ...) G_GNUC_PRINTF(3, 4);
426 char *debug_newvstrallocf(const char *file, int line, char *oldstr,
427 const char *fmt, ...) G_GNUC_PRINTF(4, 5);
429 /* Usage: vstrextend(foo, "bar, "baz", NULL). Extends the existing
430 * string, or allocates a brand new one. */
431 char *debug_vstrextend(const char *file, int line, char **oldstr, ...);
433 #define alloc(s) debug_alloc(__FILE__, __LINE__, (s))
434 #define newalloc(p,s) debug_newalloc(__FILE__, __LINE__, (p), (s))
435 #define stralloc(s) debug_stralloc(__FILE__, __LINE__, (s))
436 #define newstralloc(p,s) debug_newstralloc(__FILE__, __LINE__, (p), (s))
437 #define vstralloc(...) debug_vstralloc(__FILE__,__LINE__,__VA_ARGS__)
438 #define newvstralloc(...) debug_newvstralloc(__FILE__,__LINE__,__VA_ARGS__)
439 #define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__)
440 #define newvstrallocf(...) debug_newvstrallocf(__FILE__,__LINE__,__VA_ARGS__)
441 #define vstrextend(...) debug_vstrextend(__FILE__,__LINE__,__VA_ARGS__)
443 #define stralloc2(s1,s2) vstralloc((s1),(s2),NULL)
444 #define newstralloc2(p,s1,s2) newvstralloc((p),(s1),(s2),NULL)
446 #define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__)
448 /*@only@*/ /*@null@*/ char *debug_agets(const char *file, int line, FILE *f);
449 /*@only@*/ /*@null@*/ char *debug_areads(const char *file, int line, int fd);
450 #define agets(f) debug_agets(__FILE__,__LINE__,(f))
451 #define areads(f) debug_areads(__FILE__,__LINE__,(f))
453 /* return a "safe" version of the current environment; pass this to execle */
454 #define safe_env() safe_env_full(NULL)
456 /* like safe_env, but optionally add additional environment variables */
457 char ** safe_env_full(char **add);
459 time_t unctime(char *timestr);
462 * amfree(ptr) -- if allocated, release space and set ptr to NULL.
464 * In general, this should be called instead of just free(), unless
465 * the very next source line sets the pointer to a new value.
468 #define amfree(ptr) do { \
469 if((ptr) != NULL) { \
470 int e__errno = errno; \
474 (void)(ptr); /* Fix value never used warning at end of routines */ \
478 #define strappend(s1,s2) do { \
479 char *t_t_t = (s1) ? stralloc2((s1),(s2)) : stralloc((s2)); \
485 * Return the number of elements in an array.
487 #define am_countof(a) (int)(SIZEOF(a) / SIZEOF((a)[0]))
490 * min/max. Don't do something like
494 * because the increment will be duplicated.
498 #define min(a, b) ((a) < (b) ? (a) : (b))
499 #define max(a, b) ((a) > (b) ? (a) : (b))
502 * Utility bitmask manipulation macros.
504 #define SET(t, f) ((t) |= (f))
505 #define CLR(t, f) ((t) &= ~((unsigned)(f)))
506 #define ISSET(t, f) ((t) & (f))
509 * Utility string macros. All assume a variable holds the current
510 * character and the string pointer points to the next character to
511 * be processed. Typical setup is:
515 * skip_whitespace(s, ch);
518 * If you advance the pointer "by hand" to skip over something, do
524 * Note that ch has the character at the end of the just skipped field.
525 * It is often useful to terminate a string, make a copy, then restore
526 * the input like this:
528 * skip_whitespace(s, ch);
529 * fp = s-1; ## save the start
530 * skip_nonwhitespace(s, ch); ## find the end
531 * p[-1] = '\0'; ## temporary terminate
532 * field = stralloc(fp); ## make a copy
533 * p[-1] = ch; ## restore the input
535 * The scanning macros are:
537 * skip_whitespace (ptr, var)
538 * -- skip whitespace, but stops at a newline
539 * skip_non_whitespace (ptr, var)
540 * -- skip non whitespace
541 * skip_non_whitespace_cs (ptr, var)
542 * -- skip non whitespace, stop at comment
543 * skip_integer (ptr, var)
544 * -- skip an integer field
545 * skip_line (ptr, var)
546 * -- skip just past the next newline
547 * strncmp_const (str, const_str)
548 * -- compare str to const_str, a string constant
549 * strncmp_const_skip (str, const_var, ptr, var)
550 * -- like strncmp_const, but skip the string if a match is
551 * found; this macro only tests for equality, discarding
552 * ordering information.
556 * ptr -- string pointer
557 * var -- current character
559 * These macros copy a non-whitespace field to a new buffer, and should
560 * only be used if dynamic allocation is impossible (fixed size buffers
561 * are asking for trouble):
563 * copy_string (ptr, var, field, len, fldptr)
564 * -- copy a non-whitespace field
565 * copy_string_cs (ptr, var, field, len, fldptr)
566 * -- copy a non-whitespace field, stop at comment
570 * ptr -- string pointer
571 * var -- current character
572 * field -- area to copy to
573 * len -- length of area (needs room for null byte)
574 * fldptr -- work pointer used in move
575 * if NULL on exit, the field was too small for the input
578 #define STR_SIZE 4096 /* a generic string buffer size */
579 #define NUM_STR_SIZE 128 /* a generic number buffer size */
581 #define skip_whitespace(ptr,c) do { \
582 while((c) != '\n' && g_ascii_isspace((int)c)) (c) = *(ptr)++; \
585 #define skip_non_whitespace(ptr,c) do { \
586 while((c) != '\0' && !g_ascii_isspace((int)c)) (c) = *(ptr)++; \
589 #define skip_non_whitespace_cs(ptr,c) do { \
590 while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) (c) = *(ptr)++;\
593 #define skip_non_integer(ptr,c) do { \
594 while((c) != '\0' && !isdigit(c)) (c) = *(ptr)++; \
597 #define skip_integer(ptr,c) do { \
598 if((c) == '+' || (c) == '-') (c) = *(ptr)++; \
599 while(isdigit(c)) (c) = *(ptr)++; \
602 #define skip_quoted_string(ptr, c) do { \
604 while (((c) != '\0') && !((iq == 0) && g_ascii_isspace((int)c))) { \
607 } else if ((c) == '\\') { \
608 if (*ptr) /* not last character */ \
615 #define skip_quoted_line(ptr, c) do { \
617 while((c) && !((iq == 0) && ((c) == '\n'))) { \
626 #define skip_line(ptr,c) do { \
627 while((c) && (c) != '\n') \
633 #define copy_string(ptr,c,f,l,fp) do { \
635 while((c) != '\0' && !g_ascii_isspace((int)c)) { \
636 if((fp) >= (f) + (l) - 1) { \
639 (void)(fp); /* Fix value never used warning at end of routines */ \
649 #define copy_string_cs(ptr,c,f,l,fp) do { \
651 while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) { \
652 if((fp) >= (f) + (l) - 1) { \
663 #define is_dot_or_dotdot(s) \
666 || ((s)[1] == '.' && (s)[2] == '\0')))
668 #define strncmp_const(str, cnst) \
669 strncmp((str), (cnst), sizeof((cnst))-1)
671 /* (have to roll this up in an expression, so it can be used in if()) */
672 #define strncmp_const_skip(str, cnst, ptr, var) \
673 ((strncmp((str), (cnst), sizeof((cnst))-1) == 0)? \
674 ((ptr)+=sizeof((cnst))-1, (var)=(ptr)[-1], 0) \
677 /* from old bsd-security.c */
679 extern int check_security(sockaddr_union *, char *, unsigned long, char **);
682 * Handle functions which are not always declared on all systems. This
683 * stops gcc -Wall and lint from complaining.
686 /* AIX #defines accept, and provides a prototype for the alternate name */
687 #if !defined(HAVE_ACCEPT_DECL) && !defined(accept)
688 extern int accept(int s, struct sockaddr *addr, socklen_t_equiv *addrlen);
691 #ifndef HAVE_ATOF_DECL
692 extern double atof(const char *ptr);
696 # define bcopy(from,to,n) ((void)memmove((to), (from), (n)))
698 # ifndef HAVE_BCOPY_DECL
699 extern void bcopy(const void *s1, void *s2, size_t n);
703 #ifndef HAVE_BIND_DECL
704 extern int bind(int s, const struct sockaddr *name, socklen_t_equiv namelen);
708 #define bzero(s,n) ((void)memset((s),0,(n)))
710 # ifndef HAVE_BZERO_DECL
711 extern void bzero(void *s, size_t n);
715 #ifndef HAVE_CLOSELOG_DECL
716 extern void closelog(void);
719 #ifndef HAVE_CONNECT_DECL
720 extern int connect(int s, struct sockaddr *name, socklen_t_equiv namelen);
723 #ifndef HAVE_FCLOSE_DECL
724 extern int fclose(FILE *stream);
727 #ifndef HAVE_FFLUSH_DECL
728 extern int fflush(FILE *stream);
731 #ifndef HAVE_FPRINTF_DECL
732 extern int fprintf(FILE *stream, const char *format, ...);
735 #ifndef HAVE_FPUTC_DECL
736 extern int fputc(int c, FILE *stream);
739 #ifndef HAVE_FPUTS_DECL
740 extern int fputs(const char *s, FILE *stream);
743 #ifndef HAVE_FREAD_DECL
744 extern size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);
747 #ifndef HAVE_FSEEK_DECL
748 extern int fseek(FILE *stream, long offset, int ptrname);
751 #ifndef HAVE_FWRITE_DECL
752 extern size_t fwrite(const void *ptr, size_t size, size_t nitems,
756 #ifndef HAVE_GETHOSTNAME_DECL
757 extern int gethostname(char *name, int namelen);
760 #ifndef HAVE_GETOPT_DECL
762 extern int getopt(int argc, char * const *argv, const char *optstring);
765 /* AIX #defines getpeername, and provides a prototype for the alternate name */
766 #if !defined(HAVE_GETPEERNAME_DECL) && !defined(getpeername)
767 extern int getpeername(int s, struct sockaddr *name, socklen_t_equiv *namelen);
770 /* AIX #defines getsockname, and provides a prototype for the alternate name */
771 #if !defined(HAVE_GETSOCKNAME_DECL) && !defined(getsockname)
772 extern int getsockname(int s, struct sockaddr *name, socklen_t_equiv *namelen);
775 #ifndef HAVE_GETSOCKOPT_DECL
776 extern int getsockopt(int s, int level, int optname, char *optval,
777 socklen_t_equiv *optlen);
780 #ifndef HAVE_INITGROUPS
781 # define initgroups(name,basegid) 0
783 # ifndef HAVE_INITGROUPS_DECL
784 extern int initgroups(const char *name, gid_t basegid);
788 #ifndef HAVE_IOCTL_DECL
789 extern int ioctl(int fildes, int request, ...);
793 #ifndef HAVE_ISNORMAL
794 #define isnormal(f) (((f) < 0.0) || ((f) > 0.0))
798 #ifndef HAVE_LISTEN_DECL
799 extern int listen(int s, int backlog);
802 #ifndef HAVE_LSTAT_DECL
803 extern int lstat(const char *path, struct stat *buf);
806 #ifndef HAVE_MALLOC_DECL
807 extern void *malloc (size_t size);
810 #ifndef HAVE_MEMMOVE_DECL
812 extern void *memmove(void *to, const void *from, size_t n);
814 extern char *memmove(char *to, /*const*/ char *from, size_t n);
818 #ifndef HAVE_MEMSET_DECL
819 extern void *memset(void *s, int c, size_t n);
822 #ifndef HAVE_MKTEMP_DECL
823 extern char *mktemp(char *template);
826 #ifndef HAVE_MKSTEMP_DECL
827 extern int mkstemp(char *template);
830 #ifndef HAVE_MKTIME_DECL
831 extern time_t mktime(struct tm *timeptr);
834 #ifndef HAVE_OPENLOG_DECL
836 extern void openlog(const char *ident, int logopt, int facility);
838 extern void openlog(const char *ident, int logopt);
842 #ifndef HAVE_PCLOSE_DECL
843 extern int pclose(FILE *stream);
846 #ifndef HAVE_PERROR_DECL
847 extern void perror(const char *s);
850 #ifndef HAVE_PRINTF_DECL
851 extern int printf(const char *format, ...);
854 #ifndef HAVE_PUTS_DECL
855 extern int puts(const char *s);
858 #ifndef HAVE_REALLOC_DECL
859 extern void *realloc(void *ptr, size_t size);
862 /* AIX #defines recvfrom, and provides a prototype for the alternate name */
863 #if !defined(HAVE_RECVFROM_DECL) && !defined(recvfrom)
864 extern int recvfrom(int s, char *buf, int len, int flags,
865 struct sockaddr *from, socklen_t_equiv *fromlen);
868 #ifndef HAVE_REMOVE_DECL
869 extern int remove(const char *path);
872 #ifndef HAVE_RENAME_DECL
873 extern int rename(const char *old, const char *new);
876 #ifndef HAVE_REWIND_DECL
877 extern void rewind(FILE *stream);
880 #ifndef HAVE_RUSEROK_DECL
881 extern int ruserok(const char *rhost, int suser,
882 const char *ruser, const char *luser);
885 #ifndef HAVE_SELECT_DECL
886 extern int select(int nfds,
887 SELECT_ARG_TYPE *readfds,
888 SELECT_ARG_TYPE *writefds,
889 SELECT_ARG_TYPE *exceptfds,
890 struct timeval *timeout);
893 #ifndef HAVE_SENDTO_DECL
894 extern int sendto(int s, const char *msg, int len, int flags,
895 const struct sockaddr *to, int tolen);
898 #ifdef HAVE_SETRESGID
899 #define setegid(x) setresgid((gid_t)-1,(x),(gid_t)-1)
900 #ifndef HAVE_SETRESGID_DECL
901 extern int setresgid(gid_t rgid, gid_t egid, gid_t sgid);
904 #ifndef HAVE_SETEGID_DECL
905 extern int setegid(gid_t egid);
909 #ifdef HAVE_SETRESUID
910 #define seteuid(x) setresuid((uid_t)-1,(x),(uid_t)-1)
911 #ifndef HAVE_SETRESUID_DECL
912 extern int setresuid(uid_t ruid, uid_t euid, uid_t suid);
915 #ifndef HAVE_SETEUID_DECL
916 extern int seteuid(uid_t euid);
920 #ifndef HAVE_SETPGID_DECL
922 extern int setpgid(pid_t pid, pid_t pgid);
926 #ifndef HAVE_SETPGRP_DECL
928 extern pid_t setpgrp(void);
930 extern pid_t setpgrp(pid_t pgrp, pid_t pid);
934 #ifndef HAVE_SETSOCKOPT_DECL
935 extern int setsockopt(int s, int level, int optname,
936 const char *optval, int optlen);
940 #ifndef HAVE_SHMAT_DECL
941 extern void *shmat(int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg);
944 #ifndef HAVE_SHMCTL_DECL
945 extern int shmctl(int shmid, int cmd, struct shmid_ds *buf);
948 #ifndef HAVE_SHMDT_DECL
949 extern int shmdt(SHM_ARG_TYPE *shaddr);
952 #ifndef HAVE_SHMGET_DECL
953 extern int shmget(key_t key, size_t size, int shmflg);
957 #ifndef HAVE_SNPRINTF_DECL
959 int snprintf(char *buf, size_t len, const char *format,...)
962 #ifndef HAVE_VSNPRINTF_DECL
964 int vsnprintf(char *buf, size_t len, const char *format, va_list ap);
967 #ifndef HAVE_SOCKET_DECL
968 extern int socket(int domain, int type, int protocol);
971 #ifndef HAVE_SOCKETPAIR_DECL
972 extern int socketpair(int domain, int type, int protocol, int sv[2]);
975 #ifndef HAVE_SSCANF_DECL
976 extern int sscanf(const char *s, const char *format, ...);
979 #ifndef HAVE_STRCASECMP_DECL
980 extern int strcasecmp(const char *s1, const char *s2);
983 #ifndef HAVE_STRERROR_DECL
984 extern char *strerror(int errnum);
987 #ifndef HAVE_STRFTIME_DECL
988 extern size_t strftime(char *s, size_t maxsize, const char *format,
989 const struct tm *timeptr);
992 #ifndef HAVE_STRNCASECMP_DECL
993 extern int strncasecmp(const char *s1, const char *s2, int n);
996 #ifndef HAVE_SYSLOG_DECL
997 extern void syslog(int priority, const char *logstring, ...)
1001 #ifndef HAVE_SYSTEM_DECL
1002 extern int system(const char *string);
1005 #ifndef HAVE_TIME_DECL
1006 extern time_t time(time_t *tloc);
1009 #ifndef HAVE_TOLOWER_DECL
1010 extern int tolower(int c);
1013 #ifndef HAVE_TOUPPER_DECL
1014 extern int toupper(int c);
1017 #ifndef HAVE_UNGETC_DECL
1018 extern int ungetc(int c, FILE *stream);
1021 #ifndef HAVE_VFPRINTF_DECL
1022 #include "arglist.h"
1023 extern int vfprintf(FILE *stream, const char *format, va_list ap);
1026 #ifndef HAVE_VPRINTF_DECL
1027 #include "arglist.h"
1028 extern int vprintf(const char *format, va_list ap);
1031 /* these system headers are added by gnulib if they
1034 #include "arpa/inet.h"
1036 /* gnulib-only includes */
1037 #include "safe-read.h"
1038 #include "full-read.h"
1039 #include "full-write.h"
1041 #if !defined(S_ISCHR) && defined(_S_IFCHR) && defined(_S_IFMT)
1042 #define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR)
1045 #if !defined(S_ISREG) && defined(_S_IFREG) && defined(_S_IFMT)
1046 #define S_ISREG(mode) (((mode) & _S_IFMT) == _S_IFREG)
1049 #ifndef HAVE_WAITPID
1051 #define waitpid(pid,status,options) wait4(pid,status,options,0)
1053 extern pid_t waitpid(pid_t pid, amwait_t *stat_loc, int options);
1057 #ifndef HAVE_WRITEV_DECL
1058 extern ssize_t writev(int fd, const struct iovec *iov, int iovcnt);
1061 #ifndef STDIN_FILENO
1062 #define STDIN_FILENO 0
1065 #ifndef STDOUT_FILENO
1066 #define STDOUT_FILENO 1
1069 #ifndef STDERR_FILENO
1070 #define STDERR_FILENO 2
1073 /* S_ISDIR is not defined on Nextstep */
1075 #if defined(_S_IFMT) && defined(_S_IFDIR)
1076 #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR))
1078 #error Don t know how to define S_ISDIR
1082 #if SIZEOF_SIZE_T == SIZEOF_INT
1083 # define SIZE_T_ATOI (size_t)atoi
1085 # define SIZE_MAX G_MAXUINT
1088 # define SIZE_T_ATOI (size_t)atol
1090 # define SIZE_MAX ULONG_MAX
1094 #if SIZEOF_SSIZE_T == SIZEOF_INT
1095 # define SSIZE_T_ATOI (ssize_t)atoi
1097 # define SSIZE_MAX INT_MAX
1100 # define SSIZE_MIN INT_MIN
1103 # define SSIZE_T_ATOI (ssize_t)atol
1105 # define SSIZE_MAX LONG_MAX
1108 # define SSIZE_MIN LONG_MIN
1112 #if SIZEOF_TIME_T == SIZEOF_INT
1113 # define TIME_T_ATOI (time_t)atoi
1115 # define TIME_MAX G_MAXUINT
1118 # define TIME_T_ATOI (time_t)atol
1120 # define TIME_MAX ULONG_MAX
1124 #if SIZEOF_OFF_T > SIZEOF_LONG
1126 # define OFF_T_ATOI (off_t)atoll
1128 # define OFF_T_ATOI (off_t)atol
1130 # ifdef HAVE_STRTOLL
1131 # define OFF_T_STRTOL (off_t)strtoll
1133 # define OFF_T_STRTOL (off_t)strtol
1136 # if SIZEOF_OFF_T == SIZEOF_LONG
1137 # define OFF_T_ATOI (off_t)atol
1138 # define OFF_T_STRTOL (off_t)strtol
1140 # define OFF_T_ATOI (off_t)atoi
1141 # define OFF_T_STRTOL (off_t)strtol
1146 #define BIND_CYCLE_RETRIES 120 /* Total of 30 minutes */
1148 #define MAX_DUMPERS 63
1151 #define NI_MAXHOST 1025
1155 KENCRYPT_NONE, /* krb5 encryption not enabled */
1156 KENCRYPT_WILL_DO, /* krb5 encryption will be enabled once amanda
1157 protocol stream is closed */
1158 KENCRYPT_YES /* krb5 encryption enabled on all stream */
1161 #define DUMP_LEVELS 400
1163 /* Constants to define the number of pre-opened pipes between amandad and
1166 /* If you change these (don't!), change them in perl/Amanda/Constants.pm, too */
1167 #define DATA_FD_COUNT 3 /* number of general-use pipes */
1168 #define DATA_FD_OFFSET 50
1170 #endif /* !AMANDA_H */