X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=common-src%2Famanda.h;h=d44a765545f8c47003605f3e44f5c5799a51488a;hb=d28952249e392eb31bc8eecc53f6c477f30c617b;hp=74be276264a66dfc6b73c30b8d534704a985abf5;hpb=3ab887b9bc819a846c75dd7f2ee5d41fac22b19f;p=debian%2Famanda diff --git a/common-src/amanda.h b/common-src/amanda.h index 74be276..d44a765 100644 --- a/common-src/amanda.h +++ b/common-src/amanda.h @@ -1,6 +1,7 @@ /* * Amanda, The Advanced Maryland Automatic Network Disk Archiver - * Copyright (c) 1991-1998 University of Maryland at College Park + * Copyright (c) 1991-1999 University of Maryland at College Park + * Copyright (c) 2007-2012 Zmanda, Inc. All Rights Reserved. * All Rights Reserved. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -24,7 +25,7 @@ * file named AUTHORS, in the root directory of this distribution. */ /* - * $Id: amanda.h,v 1.66.2.7.4.5.2.14 2004/04/30 12:13:20 martinea Exp $ + * $Id: amanda.h,v 1.131 2006/07/25 18:27:56 martinea Exp $ * * the central header file included by all amanda sources */ @@ -32,33 +33,43 @@ #define AMANDA_H #ifdef HAVE_CONFIG_H -#include "config.h" +/* use a relative path here to avoid conflicting with Perl's config.h. */ +#include "../config/config.h" #endif +#include +#include + +#include "amflock.h" + /* - * I would prefer that each Amanda module include only those system headers - * that are locally needed, but on most Unixes the system header files are not - * protected against multiple inclusion, so this can lead to problems. - * - * Also, some systems put key files in different places, so by including - * everything here the rest of the system is isolated from such things. + * Force large file source even if configure guesses wrong. */ -#ifdef HAVE_ALLOCA_H -# include +#ifndef _LARGEFILE64_SOURCE +#define _LARGEFILE64_SOURCE 1 #endif -#if 0 -/* an explanation for this is available in the CHANGES file for - amanda-2.4.0b5 */ -#ifdef HAVE_ASM_BYTEORDER_H -# include -#endif +#ifndef _FILE_OFFSET_BITS +#define _FILE_OFFSET_BITS 64 #endif #ifdef HAVE_SYS_TYPES_H # include #endif +/* gnulib creates this header locally if the system doesn't provide it, + * so it uses a local ("") include */ +#include "stdint.h" + +/* + * I would prefer that each Amanda module include only those system headers + * that are locally needed, but on most Unixes the system header files are not + * protected against multiple inclusion, so this can lead to problems. + * + * Also, some systems put key files in different places, so by including + * everything here the rest of the system is isolated from such things. + */ + /* from the autoconf documentation */ #ifdef HAVE_DIRENT_H # include @@ -77,6 +88,32 @@ # endif #endif +#ifdef ENABLE_NLS +# include +# include +# define plural(String1, String2, Count) \ + (((Count) == 1) ? (String1) : (String2)) +#else +# define plural(String1, String2, Count) \ + (((Count) == 1) ? (String1) : (String2)) +# define setlocale(Which, Locale) +# define textdomain(Domain) +# define bindtextdomain(Package, Directory) +# define gettext(String) String +# define dgettext(Domain, String) String +# define dcgettext(Domain, String, Catagory) String +# define ngettext(String1, String2, Count) \ + plural((String1), (String2), (Count)) +# define dngettext(Domain, String1, String2, Count) \ + plural((String1), (String2), (Count)) +# define dcngettext(Domain, String1, String2, Count, Catagory) \ + plural((String1), (String2), (Count)) +#endif +#define T_(String) String +#ifndef SWIG /* TODO: make this go away */ +#define _(String) dgettext("amanda", (String)) +#endif + #ifdef HAVE_FCNTL_H # include #endif @@ -101,10 +138,6 @@ #endif #endif -#ifdef HAVE_NETDB_H -# include -#endif - #ifdef TIME_WITH_SYS_TIME # include # include @@ -124,6 +157,10 @@ # include #endif +#ifdef HAVE_LIBGEN_H +# include +#endif + #ifdef HAVE_STRING_H # include #endif @@ -136,6 +173,10 @@ # include #endif +#ifdef HAVE_MATH_H +# include +#endif + #ifdef HAVE_SYS_FILE_H # include #endif @@ -144,6 +185,10 @@ # include #endif +#ifdef HAVE_LIMITS_H +#include +#endif + #ifdef HAVE_SYS_PARAM_H # include #endif @@ -165,6 +210,15 @@ # include #endif +#ifdef HAVE_SYS_UIO_H +# include +#else +struct iovec { + void *iov_base; + int iov_len; +}; +#endif + #ifdef HAVE_WAIT_H # include #endif @@ -173,18 +227,11 @@ # include #endif -#ifdef WAIT_USES_UNION - typedef union wait amwait_t; -# ifndef WEXITSTATUS -# define WEXITSTATUS(stat_val) (((amwait_t*)&(stat_val))->w_retcode) -# endif -# ifndef WTERMSIG -# define WTERMSIG(stat_val) (((amwait_t*)&(stat_val))->w_termsig) -# endif -# ifndef WIFEXITED -# define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0) -# endif -#else +#ifdef HAVE_STDARG_H +#include +#endif + +#ifdef WAIT_USES_INT typedef int amwait_t; # ifndef WEXITSTATUS # define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8) @@ -195,84 +242,59 @@ # ifndef WIFEXITED # define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0) # endif +#else +# ifdef WAIT_USES_UNION + typedef union wait amwait_t; +# ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) (((amwait_t*)&(stat_val))->w_retcode) +# endif +# ifndef WTERMSIG +# define WTERMSIG(stat_val) (((amwait_t*)&(stat_val))->w_termsig) +# endif +# ifndef WIFEXITED +# define WIFEXITED(stat_val) (WTERMSIG(stat_val) == 0) +# endif +# else + typedef int amwait_t; +# ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) (*(unsigned*)&(stat_val) >> 8) +# endif +# ifndef WTERMSIG +# define WTERMSIG(stat_val) (*(unsigned*)&(stat_val) & 0x7F) +# endif +# ifndef WIFEXITED +# define WIFEXITED(stat_val) ((*(unsigned*)&(stat_val) & 255) == 0) +# endif +# endif +#endif + +#ifndef WIFSIGNALED +# define WIFSIGNALED(stat_val) (WTERMSIG(stat_val) != 0) #endif #ifdef HAVE_UNISTD_H # include #endif -/* - * At present, the kerberos routines require atexit(), or equivilent. If - * you're not using kerberos, you don't need it at all. If you just null - * out the definition, you'll end up with ticket files hanging around in - * /tmp. - */ -#if defined(KRB4_SECURITY) -# if !defined(HAVE_ATEXIT) -# if defined(HAVE_ON_EXIT) -# define atexit(func) on_exit(func, 0) -# else -# define atexit(func) (you must to resolve lack of atexit in amanda.h) -# endif -# endif +#ifdef HAVE_NETINET_IN_H +# include #endif #include #include -#include #include #include #include #include #include #include -#if !defined(CONFIGURE_TEST) -# include "amanda-int.h" -#endif -#ifdef HAVE_ARPA_INET_H -#include +#ifdef WORKING_IPV6 +#define INET6 #endif -#ifdef KRB4_SECURITY -# include -# include -#endif - -/* - * The dbmalloc package comes from: - * - * http://www.clark.net/pub/dickey/dbmalloc/dbmalloc.tar.gz - * - * or - * - * ftp://gatekeeper.dec.com/pub/usenet/comp.sources.misc/volume32/dbmalloc/ - * - * The following functions are sprinkled through the code, but are - * disabled unless USE_DBMALLOC is defined: - * - * malloc_enter(char *) -- stack trace for malloc reports - * malloc_leave(char *) -- stack trace for malloc reports - * malloc_mark(void *) -- mark an area as never to be free-d - * malloc_chain_check(void) -- check the malloc area now - * malloc_dump(int fd) -- report the malloc contents to a file descriptor - * malloc_list(int fd, ulong a, ulong b) -- report memory activated since - * history stamp a that is still active as of stamp b (leak check) - * malloc_inuse(ulong *h) -- create history stamp h and return the amount - * of memory currently in use. - */ - -#ifdef USE_DBMALLOC -#include "dbmalloc.h" -#else -#define malloc_enter(func) -#define malloc_leave(func) -#define malloc_mark(ptr) -#define malloc_chain_check() -#define malloc_dump(fd) -#define malloc_list(a,b,c) -#define malloc_inuse(hist) (*(hist) = 0, 0) -#define dbmalloc_caller_loc(x,y) (x) +#ifndef INET_ADDRSTRLEN +#define INET_ADDRSTRLEN 16 #endif #if !defined(HAVE_SIGACTION) && defined(HAVE_SIGVEC) @@ -292,16 +314,35 @@ extern int errno; #endif +/* + * Some compilers have int for type of sizeof() some use size_t. + * size_t is the one we want... + */ +#define SIZEOF(x) (size_t)sizeof(x) + /* * Some older BSD systems don't have these FD_ macros, so if not, provide them. */ -#ifndef FD_SET -# define FD_SETSIZE (sizeof(fd_set) * 8) -# define FD_SET(n, p) (((fd_set *) (p))->fds_bits[0] |= (1 << ((n) % 32))) -# define FD_CLR(n, p) (((fd_set *) (p))->fds_bits[0] &= ~(1 << ((n) % 32))) -# define FD_ISSET(n, p) (((fd_set *) (p))->fds_bits[0] & (1 << ((n) % 32))) -# define FD_ZERO(p) memset((p), 0, sizeof(*(p))) +#if !defined(FD_SET) || defined(LINT) || defined(__lint) +# undef FD_SETSIZE +# define FD_SETSIZE (int)(SIZEOF(fd_set) * CHAR_BIT) + +# undef FD_SET +# define FD_SET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] |= (int)((1 << ((n) % WORD_BIT)))) + +# undef FD_CLR +# define FD_CLR(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] &= (int)(~(1 << ((n) % WORD_BIT)))) + +# undef FD_ISSET +# define FD_ISSET(n, p) (((fd_set *)(p))->fds_bits[(n)/WORD_BIT] & (1 << ((n) % WORD_BIT))) + +# undef FD_ZERO +# define FD_ZERO(p) memset((p), 0, SIZEOF(*(p))) +#endif + +#ifndef FD_COPY +# define FD_COPY(p, q) memcpy((q), (p), SIZEOF(*(p))) #endif @@ -318,79 +359,13 @@ extern int errno; # define void char #endif -/* - * define prototype macro so that prototypes can be declared in both ANSI - * and classic C environments. - */ -#if STDC_HEADERS -# define P(parms) parms -# define stringize(x) #x -#else -# define P(parms) () -# define stringize(x) "x" -#endif - -/* - * So that we can use GNUC attributes (such as to get -Wall warnings - * for printf-like functions). Only do this in gcc 2.7 or later ... - * it may work on earlier stuff, but why chance it. - */ -#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 7 -#define __attribute__(__x) -#endif - -/* - * assertions, but call error() instead of abort - */ -#ifndef ASSERTIONS - -#define assert(exp) ((void)0) - -#else /* ASSERTIONS */ - -#define assert(exp) {if(!(exp)) error("assert: %s false, file %s, line %d", \ - stringize(exp), __FILE__, __LINE__);} - -#endif /* ASSERTIONS */ - -/* - * print debug output, else compile to nothing. - */ - -#ifdef DEBUG_CODE /* { */ -# define dbopen() debug_open() -# define dbclose() debug_close() -# define dbprintf(p) (debug? (debug_printf p, 0) : 0) -# define dbfd() debug_fd() -# define dbfp() debug_fp() -# define dbfn() debug_fn() - -extern void debug_open P((void)); -extern void debug_close P((void)); -extern void debug_printf P((char *format, ...)) - __attribute__ ((format (printf, 1, 2))); -extern int debug_fd P((void)); -extern FILE * debug_fp P((void)); -extern char * debug_fn P((void)); -extern void set_debug_prefix_pid P((pid_t)); -extern char *debug_prefix P((char *)); -extern char *debug_prefix_time P((char *)); -#else /* }{ */ -# define dbopen() -# define dbclose() -# define dbprintf(p) -# define dbfd() (-1) -# define dbfp() NULL -# define dbfn() NULL -# define set_debug_prefix_pid(x) -# define debug_prefix(x) get_pname() -# define debug_prefix_time(x) get_pname() -#endif /* } */ +#define stringize(x) #x +#define stringconcat(x, y) x ## y /* amanda #days calculation, with roundoff */ #define SECS_PER_DAY (24*60*60) -#define days_diff(a, b) (((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY) +#define days_diff(a, b) (int)(((b) - (a) + SECS_PER_DAY/2) / SECS_PER_DAY) /* Global constants. */ #ifndef AMANDA_SERVICE_NAME @@ -403,143 +378,86 @@ extern char *debug_prefix_time P((char *)); #define SERVICE_SUFFIX "" #endif #ifndef AMANDA_SERVICE_DEFAULT -#define AMANDA_SERVICE_DEFAULT 10080 +#define AMANDA_SERVICE_DEFAULT ((in_port_t)10080) #endif #ifndef KAMANDA_SERVICE_DEFAULT -#define KAMANDA_SERVICE_DEFAULT 10081 +#define KAMANDA_SERVICE_DEFAULT ((in_port_t)10081) #endif #define am_round(v,u) ((((v) + (u) - 1) / (u)) * (u)) #define am_floor(v,u) (((v) / (u)) * (u)) -/* Holding disk block size. Do not even think about changing this! :-) */ +/* Holding disk block size. Do not even think about changint this! :-) */ #define DISK_BLOCK_KB 32 #define DISK_BLOCK_BYTES (DISK_BLOCK_KB * 1024) -/* Maximum size of a tape block */ -/* MAX_TAPE_BLOCK_KB is defined in config.h */ -/* by configure --with-maxtapeblocksize */ -#define MAX_TAPE_BLOCK_BYTES (MAX_TAPE_BLOCK_KB*1024) - -/* Define miscellaneous amanda functions. */ -#define ERR_INTERACTIVE 1 -#define ERR_SYSLOG 2 -#define ERR_AMANDALOG 4 - -/* For static buffer manager [alloc.c:sbuf_man()] */ -#define SBUF_MAGIC 42 -#define SBUF_DEF(name, len) static SBUF2_DEF(len) name = {SBUF_MAGIC, len, -1} -#define SBUF2_DEF(len) \ - struct { \ - int magic; \ - int max, cur; \ - void *bufp[len]; \ - } - -extern void set_logerror P((void (*f)(char *))); -extern void set_pname P((char *pname)); -extern char *get_pname P((void)); -extern int erroutput_type; -extern void error P((char *format, ...)) - __attribute__ ((format (printf, 1, 2))); -extern void errordump P((char *format, ...)) - __attribute__ ((format (printf, 1, 2))); -extern int onerror P((void (*errf)(void))); - -extern void *debug_alloc P((char *c, int l, size_t size)); -extern void *debug_newalloc P((char *c, int l, void *old, size_t size)); -extern char *debug_stralloc P((char *c, int l, const char *str)); -extern char *debug_newstralloc P((char *c, int l, char *oldstr, const char *newstr)); -extern char *debug_caller_loc P((char *file, int line)); - -extern int debug_alloc_push P((char *file, int line)); -extern void debug_alloc_pop P((void)); +/* Maximum length of tape label, plus one for null-terminator. */ +#define MAX_TAPE_LABEL_LEN (10240) +#define MAX_TAPE_LABEL_BUF (MAX_TAPE_LABEL_LEN+1) +#define MAX_TAPE_LABEL_FMT "%10240s" + +/* Unfortunately, the system-level sockaddr_storage definition can lead to + * C aliasing errors (where the optimizer doesn't notice that two operations + * affect the same datum). We define our own similar type as a union. + */ +typedef union sockaddr_union { + struct sockaddr sa; + struct sockaddr_in sin; +#ifdef WORKING_IPV6 + struct sockaddr_in6 sin6; +#endif +#ifdef HAVE_SOCKADDR_STORAGE + struct sockaddr_storage ss; /* not used; just here to make the union full-size */ +#endif +} sockaddr_union; + +#include "debug.h" +#include "file.h" + +void *debug_alloc(const char *file, int line, size_t size); +void *debug_newalloc(const char *file, int line, void *old, size_t size); +char *debug_stralloc(const char *file, int line, const char *str); +char *debug_newstralloc(const char *file, int line, + char *oldstr, const char *newstr); +char *debug_vstralloc(const char *file, int line, const char *str, ...); +char *debug_newvstralloc(const char *file, int line, + char *oldstr, const char *str, ...); +char *debug_vstrallocf(const char *file, int line, const char *fmt, + ...) G_GNUC_PRINTF(3, 4); +char *debug_newvstrallocf(const char *file, int line, char *oldstr, + const char *fmt, ...) G_GNUC_PRINTF(4, 5); + +/* Usage: vstrextend(foo, "bar, "baz", NULL). Extends the existing + * string, or allocates a brand new one. */ +char *debug_vstrextend(const char *file, int line, char **oldstr, ...); #define alloc(s) debug_alloc(__FILE__, __LINE__, (s)) #define newalloc(p,s) debug_newalloc(__FILE__, __LINE__, (p), (s)) #define stralloc(s) debug_stralloc(__FILE__, __LINE__, (s)) #define newstralloc(p,s) debug_newstralloc(__FILE__, __LINE__, (p), (s)) +#define vstralloc(...) debug_vstralloc(__FILE__,__LINE__,__VA_ARGS__) +#define newvstralloc(...) debug_newvstralloc(__FILE__,__LINE__,__VA_ARGS__) +#define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__) +#define newvstrallocf(...) debug_newvstrallocf(__FILE__,__LINE__,__VA_ARGS__) +#define vstrextend(...) debug_vstrextend(__FILE__,__LINE__,__VA_ARGS__) -/* - * Voodoo time. We want to be able to mark these calls with the source - * line, but CPP does not handle variable argument lists so we cannot - * do what we did above (e.g. for alloc()). - * - * What we do is call a function to save the file and line number - * and have it return "false". That triggers the "?" operator to - * the right side of the ":" which is a call to the debug version of - * vstralloc/newvstralloc but without parameters. The compiler gets - * those from the next input tokens: - * - * xx = vstralloc(a,b,NULL); - * - * becomes: - * - * xx = debug_alloc_push(__FILE__,__LINE__)?0:debug_vstralloc(a,b,NULL); - * - * This works as long as vstralloc/newvstralloc are not part of anything - * very complicated. Assignment is fine, as is an argument to another - * function (but you should not do that because it creates a memory leak). - * This will not work in arithmetic or comparison, but it is unlikely - * they are used like that. - * - * xx = vstralloc(a,b,NULL); OK - * return vstralloc(j,k,NULL); OK - * sub(a, vstralloc(g,h,NULL), z); OK, but a leak - * if(vstralloc(s,t,NULL) == NULL) { ... NO, but unneeded - * xx = vstralloc(x,y,NULL) + 13; NO, but why do it? - */ - -#define vstralloc debug_alloc_push(__FILE__,__LINE__)?0:debug_vstralloc -#define newvstralloc debug_alloc_push(__FILE__,__LINE__)?0:debug_newvstralloc +#define stralloc2(s1,s2) vstralloc((s1),(s2),NULL) +#define newstralloc2(p,s1,s2) newvstralloc((p),(s1),(s2),NULL) -extern char *debug_vstralloc P((const char *str, ...)); -extern char *debug_newvstralloc P((char *oldstr, const char *newstr, ...)); +#define vstrallocf(...) debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__) -#define stralloc2(s1,s2) vstralloc((s1),(s2),NULL) -#define newstralloc2(p,s1,s2) newvstralloc((p),(s1),(s2),NULL) - -extern char *debug_agets P((char *c, int l, FILE *file)); -extern char *debug_areads P((char *c, int l, int fd)); +/*@only@*/ /*@null@*/ char *debug_agets(const char *file, int line, FILE *f); +/*@only@*/ /*@null@*/ char *debug_areads(const char *file, int line, int fd); #define agets(f) debug_agets(__FILE__,__LINE__,(f)) #define areads(f) debug_areads(__FILE__,__LINE__,(f)) -extern int debug_amtable_alloc P((char *file, - int line, - void **table, - int *current, - size_t elsize, - int count, - int bump, - void (*init_func)(void *))); -#define amtable_alloc(t,c,s,n,b,f) debug_amtable_alloc(__FILE__, \ - __LINE__, \ - (t), \ - (c), \ - (s), \ - (n), \ - (b), \ - (f)) -extern void amtable_free P((void **table, int *current)); - -extern void *sbuf_man P((void *bufs, void *ptr)); -extern uid_t client_uid; -extern gid_t client_gid; -extern void safe_cd P((void)); -extern void save_core P((void)); -extern char **safe_env P((void)); -extern char *validate_regexp P((char *regex)); -extern char *validate_glob P((char *glob)); -extern char *clean_regex P((char *regex)); -extern int match P((char *regex, char *str)); -extern int match_glob P((char *glob, char *str)); -extern char *glob_to_regex P((char *glob)); -extern int match_host P((char *glob, char *host)); -extern int match_disk P((char *glob, char *disk)); -extern int match_datestamp P((char *dateexp, char *datestamp)); -extern time_t unctime P((char *timestr)); -extern ssize_t areads_dataready P((int fd)); -extern void areads_relbuf P((int fd)); +/* return a "safe" version of the current environment; pass this to execle */ +#define safe_env() safe_env_full(NULL) + +/* like safe_env, but optionally add additional environment variables */ +char ** safe_env_full(char **add); + +time_t unctime(char *timestr); /* * amfree(ptr) -- if allocated, release space and set ptr to NULL. @@ -549,13 +467,14 @@ extern void areads_relbuf P((int fd)); */ #define amfree(ptr) do { \ - if(ptr) { \ + if((ptr) != NULL) { \ int e__errno = errno; \ free(ptr); \ (ptr) = NULL; \ errno = e__errno; \ + (void)(ptr); /* Fix value never used warning at end of routines */ \ } \ -} while(0) +} while (0) #define strappend(s1,s2) do { \ char *t_t_t = (s1) ? stralloc2((s1),(s2)) : stralloc((s2)); \ @@ -563,53 +482,10 @@ extern void areads_relbuf P((int fd)); (s1) = t_t_t; \ } while(0) -/* - * "Safe" close macros. Close the object then set it to a value that - * will cause an error if referenced. - * - * aclose(fd) -- close a file descriptor and set it to -1. - * afclose(f) -- close a stdio file and set it to NULL. - * apclose(p) -- close a stdio pipe file and set it to NULL. - * - * Note: be careful not to do the following: - * - * for(fd = low; fd < high; fd++) { - * aclose(fd); - * } - * - * Since aclose() sets the argument to -1, this will loop forever. - * Just copy fd to a temp variable and use that with aclose(). - * - * Aclose() interacts with areads() to inform it to release any buffer - * it has outstanding on the file descriptor. - */ - -#define aclose(fd) do { \ - if((fd) >= 0) { \ - close(fd); \ - areads_relbuf(fd); \ - } \ - (fd) = -1; \ -} while(0) - -#define afclose(f) do { \ - if((f) != NULL) { \ - fclose(f); \ - } \ - (f) = NULL; \ -} while(0) - -#define apclose(p) do { \ - if((p) != NULL) { \ - pclose(p); \ - } \ - (p) = NULL; \ -} while(0) - /* * Return the number of elements in an array. */ -#define am_countof(a) (sizeof(a) / sizeof((a)[0])) +#define am_countof(a) (int)(SIZEOF(a) / SIZEOF((a)[0])) /* * min/max. Don't do something like @@ -620,8 +496,15 @@ extern void areads_relbuf P((int fd)); */ #undef min #undef max -#define min(a, b) ((a) < (b) ? (a) : (b)) -#define max(a, b) ((a) > (b) ? (a) : (b)) +#define min(a, b) ((a) < (b) ? (a) : (b)) +#define max(a, b) ((a) > (b) ? (a) : (b)) + +/* + * Utility bitmask manipulation macros. + */ +#define SET(t, f) ((t) |= (f)) +#define CLR(t, f) ((t) &= ~((unsigned)(f))) +#define ISSET(t, f) ((t) & (f)) /* * Utility string macros. All assume a variable holds the current @@ -662,6 +545,12 @@ extern void areads_relbuf P((int fd)); * -- skip an integer field * skip_line (ptr, var) * -- skip just past the next newline + * strncmp_const (str, const_str) + * -- compare str to const_str, a string constant + * strncmp_const_skip (str, const_var, ptr, var) + * -- like strncmp_const, but skip the string if a match is + * found; this macro only tests for equality, discarding + * ordering information. * * where: * @@ -687,19 +576,19 @@ extern void areads_relbuf P((int fd)); * if NULL on exit, the field was too small for the input */ -#define STR_SIZE 1024 /* a generic string buffer size */ -#define NUM_STR_SIZE 32 /* a generic number buffer size */ +#define STR_SIZE 4096 /* a generic string buffer size */ +#define NUM_STR_SIZE 128 /* a generic number buffer size */ #define skip_whitespace(ptr,c) do { \ - while((c) != '\n' && isspace(c)) (c) = *(ptr)++; \ + while((c) != '\n' && g_ascii_isspace((int)c)) (c) = *(ptr)++; \ } while(0) #define skip_non_whitespace(ptr,c) do { \ - while((c) != '\0' && !isspace(c)) (c) = *(ptr)++; \ + while((c) != '\0' && !g_ascii_isspace((int)c)) (c) = *(ptr)++; \ } while(0) #define skip_non_whitespace_cs(ptr,c) do { \ - while((c) != '\0' && (c) != '#' && !isspace(c)) (c) = *(ptr)++; \ + while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) (c) = *(ptr)++;\ } while(0) #define skip_non_integer(ptr,c) do { \ @@ -711,28 +600,56 @@ extern void areads_relbuf P((int fd)); while(isdigit(c)) (c) = *(ptr)++; \ } while(0) +#define skip_quoted_string(ptr, c) do { \ + int iq = 0; \ + while (((c) != '\0') && !((iq == 0) && g_ascii_isspace((int)c))) { \ + if ((c) == '"') { \ + iq = !iq; \ + } else if ((c) == '\\') { \ + if (*ptr) /* not last character */ \ + (ptr)++; \ + } \ + (c) = *(ptr)++; \ + } \ +} while (0) + +#define skip_quoted_line(ptr, c) do { \ + int iq = 0; \ + while((c) && !((iq == 0) && ((c) == '\n'))) { \ + if ((c) == '"') \ + iq = !iq; \ + (c) = *(ptr)++; \ + } \ + if(c) \ + (c) = *(ptr)++; \ +} while(0) + #define skip_line(ptr,c) do { \ - while((c) && (c) != '\n') (c) = *(ptr)++; \ - if(c) (c) = *(ptr)++; \ + while((c) && (c) != '\n') \ + (c) = *(ptr)++; \ + if(c) \ + (c) = *(ptr)++; \ } while(0) #define copy_string(ptr,c,f,l,fp) do { \ (fp) = (f); \ - while((c) != '\0' && !isspace(c)) { \ + while((c) != '\0' && !g_ascii_isspace((int)c)) { \ if((fp) >= (f) + (l) - 1) { \ *(fp) = '\0'; \ (fp) = NULL; \ + (void)(fp); /* Fix value never used warning at end of routines */ \ break; \ } \ *(fp)++ = (c); \ (c) = *(ptr)++; \ } \ - if(fp) *fp = '\0'; \ + if(fp) \ + *fp = '\0'; \ } while(0) #define copy_string_cs(ptr,c,f,l,fp) do { \ (fp) = (f); \ - while((c) != '\0' && (c) != '#' && !isspace(c)) { \ + while((c) != '\0' && (c) != '#' && !g_ascii_isspace((int)c)) { \ if((fp) >= (f) + (l) - 1) { \ *(fp) = '\0'; \ (fp) = NULL; \ @@ -749,23 +666,18 @@ extern void areads_relbuf P((int fd)); && ((s)[1] == '\0' \ || ((s)[1] == '.' && (s)[2] == '\0'))) -/* from amflock.c */ -extern int amflock P((int fd, char *resource)); -extern int amroflock P((int fd, char *resource)); -extern int amfunlock P((int fd, char *resource)); +#define strncmp_const(str, cnst) \ + strncmp((str), (cnst), sizeof((cnst))-1) -/* from file.c */ -extern int mkpdir P((char *file, int mode, uid_t uid, gid_t gid)); -extern int rmpdir P((char *file, char *topdir)); -extern char *sanitise_filename P((char *inp)); +/* (have to roll this up in an expression, so it can be used in if()) */ +#define strncmp_const_skip(str, cnst, ptr, var) \ + ((strncmp((str), (cnst), sizeof((cnst))-1) == 0)? \ + ((ptr)+=sizeof((cnst))-1, (var)=(ptr)[-1], 0) \ + :1) +/* from old bsd-security.c */ extern int debug; -extern char *version_info[]; - -/* from security.c */ -extern int security_ok P((struct sockaddr_in *addr, - char *str, uint32_t cksum, char **errstr)); -extern char *get_bsd_security P((void)); +extern int check_security(sockaddr_union *, char *, unsigned long, char **); /* * Handle functions which are not always declared on all systems. This @@ -774,390 +686,359 @@ extern char *get_bsd_security P((void)); /* AIX #defines accept, and provides a prototype for the alternate name */ #if !defined(HAVE_ACCEPT_DECL) && !defined(accept) -extern int accept P((int s, struct sockaddr *addr, int *addrlen)); +extern int accept(int s, struct sockaddr *addr, socklen_t_equiv *addrlen); #endif #ifndef HAVE_ATOF_DECL -extern double atof P((const char *ptr)); +extern double atof(const char *ptr); #endif #ifndef HAVE_BCOPY # define bcopy(from,to,n) ((void)memmove((to), (from), (n))) #else # ifndef HAVE_BCOPY_DECL -extern void bcopy P((const void *s1, void *s2, size_t n)); +extern void bcopy(const void *s1, void *s2, size_t n); # endif #endif #ifndef HAVE_BIND_DECL -extern int bind P((int s, const struct sockaddr *name, int namelen)); +extern int bind(int s, const struct sockaddr *name, socklen_t_equiv namelen); #endif #ifndef HAVE_BZERO #define bzero(s,n) ((void)memset((s),0,(n))) #else # ifndef HAVE_BZERO_DECL -extern void bzero P((void *s, size_t n)); +extern void bzero(void *s, size_t n); # endif #endif #ifndef HAVE_CLOSELOG_DECL -extern void closelog P((void)); +extern void closelog(void); #endif #ifndef HAVE_CONNECT_DECL -extern int connect P((int s, struct sockaddr *name, int namelen)); -#endif - -#if !defined(TEXTDB) && !defined(HAVE_DBM_OPEN_DECL) -#undef DBM_INSERT -#define DBM_INSERT 0 - -#undef DBM_REPLACE -#define DBM_REPLACE 1 - - typedef struct { - int dummy[10]; - } DBM; - -#ifndef HAVE_STRUCT_DATUM - typedef struct { - char *dptr; - int dsize; - } datum; -#endif - - extern DBM *dbm_open P((char *file, int flags, int mode)); - extern void dbm_close P((DBM *db)); - extern datum dbm_fetch P((DBM *db, datum key)); - extern datum dbm_firstkey P((DBM *db)); - extern datum dbm_nextkey P((DBM *db)); - extern int dbm_delete P((DBM *db, datum key)); - extern int dbm_store P((DBM *db, datum key, datum content, int flg)); +extern int connect(int s, struct sockaddr *name, socklen_t_equiv namelen); #endif #ifndef HAVE_FCLOSE_DECL -extern int fclose P((FILE *stream)); +extern int fclose(FILE *stream); #endif #ifndef HAVE_FFLUSH_DECL -extern int fflush P((FILE *stream)); +extern int fflush(FILE *stream); #endif #ifndef HAVE_FPRINTF_DECL -extern int fprintf P((FILE *stream, const char *format, ...)); +extern int fprintf(FILE *stream, const char *format, ...); #endif #ifndef HAVE_FPUTC_DECL -extern int fputc P((int c, FILE *stream)); +extern int fputc(int c, FILE *stream); #endif #ifndef HAVE_FPUTS_DECL -extern int fputs P((const char *s, FILE *stream)); +extern int fputs(const char *s, FILE *stream); #endif #ifndef HAVE_FREAD_DECL -extern size_t fread P((void *ptr, size_t size, size_t nitems, FILE *stream)); +extern size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream); #endif #ifndef HAVE_FSEEK_DECL -extern int fseek P((FILE *stream, long offset, int ptrname)); +extern int fseek(FILE *stream, long offset, int ptrname); #endif #ifndef HAVE_FWRITE_DECL -extern size_t fwrite P((const void *ptr, size_t size, size_t nitems, - FILE *stream)); +extern size_t fwrite(const void *ptr, size_t size, size_t nitems, + FILE *stream); #endif #ifndef HAVE_GETHOSTNAME_DECL -extern int gethostname P((char *name, int namelen)); +extern int gethostname(char *name, int namelen); #endif #ifndef HAVE_GETOPT_DECL extern char *optarg; -extern int getopt P((int argc, char * const *argv, const char *optstring)); +extern int getopt(int argc, char * const *argv, const char *optstring); #endif /* AIX #defines getpeername, and provides a prototype for the alternate name */ #if !defined(HAVE_GETPEERNAME_DECL) && !defined(getpeername) -extern int getpeername P((int s, struct sockaddr *name, int *namelen)); +extern int getpeername(int s, struct sockaddr *name, socklen_t_equiv *namelen); #endif /* AIX #defines getsockname, and provides a prototype for the alternate name */ #if !defined(HAVE_GETSOCKNAME_DECL) && !defined(getsockname) -extern int getsockname P((int s, struct sockaddr *name, int *namelen)); +extern int getsockname(int s, struct sockaddr *name, socklen_t_equiv *namelen); #endif #ifndef HAVE_GETSOCKOPT_DECL -extern int getsockopt P((int s, int level, int optname, char *optval, - int *optlen)); -#endif - -#ifndef HAVE_GETTIMEOFDAY_DECL -# ifdef HAVE_TWO_ARG_GETTIMEOFDAY -extern int gettimeofday P((struct timeval *tp, struct timezone *tzp)); -# else -extern int gettimeofday P((struct timeval *tp)); -# endif +extern int getsockopt(int s, int level, int optname, char *optval, + socklen_t_equiv *optlen); #endif #ifndef HAVE_INITGROUPS # define initgroups(name,basegid) 0 #else # ifndef HAVE_INITGROUPS_DECL -/* modification by BIS@BBN 5/20/2003: - * In some Unix systems, basegid is defined as a gid_t; in others - * it is defined as an int. On Mac OS X, there is a "pre-compiled" - * unistd.h which causes the gcc -E command in the ICE_CHECK_DECL - * autoconf macro to not succeed. Thus, on Mac OS X, configure thinks - * we don't have this declaration when we actually do. Since Mac OS X - * defines basegid as an int, this declaration causes a compilation - * failure. The path of least resistance for fixing this problem - * is to just change the basegid declaration from gid_t to int, since - * other (but not all) UNIX flavors also defined basegid as an int. -extern int initgroups P((const char *name, gid_t basegid)); - */ -extern int initgroups P((const char *name, int basegid)); +extern int initgroups(const char *name, gid_t basegid); # endif #endif #ifndef HAVE_IOCTL_DECL -extern int ioctl P((int fildes, int request, ...)); +extern int ioctl(int fildes, int request, ...); +#endif + +#ifndef isnormal +#ifndef HAVE_ISNORMAL +#define isnormal(f) (((f) < 0.0) || ((f) > 0.0)) +#endif #endif #ifndef HAVE_LISTEN_DECL -extern int listen P((int s, int backlog)); +extern int listen(int s, int backlog); #endif #ifndef HAVE_LSTAT_DECL -extern int lstat P((const char *path, struct stat *buf)); +extern int lstat(const char *path, struct stat *buf); #endif #ifndef HAVE_MALLOC_DECL -extern void *malloc P((size_t size)); +extern void *malloc (size_t size); #endif #ifndef HAVE_MEMMOVE_DECL #ifdef HAVE_MEMMOVE -extern void *memmove P((void *to, const void *from, size_t n)); +extern void *memmove(void *to, const void *from, size_t n); #else -extern char *memmove P((char *to, /*const*/ char *from, size_t n)); +extern char *memmove(char *to, /*const*/ char *from, size_t n); #endif #endif #ifndef HAVE_MEMSET_DECL -extern void *memset P((void *s, int c, size_t n)); +extern void *memset(void *s, int c, size_t n); #endif #ifndef HAVE_MKTEMP_DECL -extern char *mktemp P((char *template)); +extern char *mktemp(char *template); +#endif + +#ifndef HAVE_MKSTEMP_DECL +extern int mkstemp(char *template); #endif #ifndef HAVE_MKTIME_DECL -extern time_t mktime P((struct tm *timeptr)); +extern time_t mktime(struct tm *timeptr); #endif #ifndef HAVE_OPENLOG_DECL #ifdef LOG_AUTH -extern void openlog P((const char *ident, int logopt, int facility)); +extern void openlog(const char *ident, int logopt, int facility); #else -extern void openlog P((const char *ident, int logopt)); +extern void openlog(const char *ident, int logopt); #endif #endif #ifndef HAVE_PCLOSE_DECL -extern int pclose P((FILE *stream)); +extern int pclose(FILE *stream); #endif #ifndef HAVE_PERROR_DECL -extern void perror P((const char *s)); +extern void perror(const char *s); #endif #ifndef HAVE_PRINTF_DECL -extern int printf P((const char *format, ...)); +extern int printf(const char *format, ...); #endif #ifndef HAVE_PUTS_DECL -extern int puts P((const char *s)); +extern int puts(const char *s); #endif #ifndef HAVE_REALLOC_DECL -extern void *realloc P((void *ptr, size_t size)); +extern void *realloc(void *ptr, size_t size); #endif /* AIX #defines recvfrom, and provides a prototype for the alternate name */ #if !defined(HAVE_RECVFROM_DECL) && !defined(recvfrom) -extern int recvfrom P((int s, char *buf, int len, int flags, - struct sockaddr *from, int *fromlen)); +extern int recvfrom(int s, char *buf, int len, int flags, + struct sockaddr *from, socklen_t_equiv *fromlen); #endif #ifndef HAVE_REMOVE_DECL -extern int remove P((const char *path)); +extern int remove(const char *path); #endif #ifndef HAVE_RENAME_DECL -extern int rename P((const char *old, const char *new)); +extern int rename(const char *old, const char *new); #endif #ifndef HAVE_REWIND_DECL -extern void rewind P((FILE *stream)); +extern void rewind(FILE *stream); #endif #ifndef HAVE_RUSEROK_DECL -extern int ruserok P((const char *rhost, int suser, - const char *ruser, const char *luser)); +extern int ruserok(const char *rhost, int suser, + const char *ruser, const char *luser); #endif #ifndef HAVE_SELECT_DECL -extern int select P((int nfds, +extern int select(int nfds, SELECT_ARG_TYPE *readfds, SELECT_ARG_TYPE *writefds, SELECT_ARG_TYPE *exceptfds, - struct timeval *timeout)); + struct timeval *timeout); #endif #ifndef HAVE_SENDTO_DECL -extern int sendto P((int s, const char *msg, int len, int flags, - const struct sockaddr *to, int tolen)); +extern int sendto(int s, const char *msg, int len, int flags, + const struct sockaddr *to, int tolen); #endif #ifdef HAVE_SETRESGID -#define setegid(x) setresgid(-1,(x),-1) +#define setegid(x) setresgid((gid_t)-1,(x),(gid_t)-1) #ifndef HAVE_SETRESGID_DECL -extern int setresgid P((gid_t rgid, gid_t egid, gid_t sgid)); +extern int setresgid(gid_t rgid, gid_t egid, gid_t sgid); #endif #else #ifndef HAVE_SETEGID_DECL -extern int setegid P((gid_t egid)); +extern int setegid(gid_t egid); #endif #endif #ifdef HAVE_SETRESUID -#define seteuid(x) setresuid(-1,(x),-1) +#define seteuid(x) setresuid((uid_t)-1,(x),(uid_t)-1) #ifndef HAVE_SETRESUID_DECL -extern int setresuid P((uid_t ruid, uid_t euid, uid_t suid)); +extern int setresuid(uid_t ruid, uid_t euid, uid_t suid); #endif #else #ifndef HAVE_SETEUID_DECL -extern int seteuid P((uid_t euid)); +extern int seteuid(uid_t euid); #endif #endif #ifndef HAVE_SETPGID_DECL #ifdef HAVE_SETPGID -extern int setpgid P((int pid, int pgid)); +extern int setpgid(pid_t pid, pid_t pgid); #endif #endif #ifndef HAVE_SETPGRP_DECL #ifdef SETPGRP_VOID -extern pid_t setpgrp P((void)); +extern pid_t setpgrp(void); #else -extern pid_t setpgrp P((int pgrp, int pid)); +extern pid_t setpgrp(pid_t pgrp, pid_t pid); #endif #endif #ifndef HAVE_SETSOCKOPT_DECL -extern int setsockopt P((int s, int level, int optname, - const char *optval, int optlen)); +extern int setsockopt(int s, int level, int optname, + const char *optval, int optlen); #endif #ifdef HAVE_SHMGET #ifndef HAVE_SHMAT_DECL -extern void *shmat P((int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg)); +extern void *shmat(int shmid, const SHM_ARG_TYPE *shmaddr, int shmflg); #endif #ifndef HAVE_SHMCTL_DECL -extern int shmctl P((int shmid, int cmd, struct shmid_ds *buf)); +extern int shmctl(int shmid, int cmd, struct shmid_ds *buf); #endif #ifndef HAVE_SHMDT_DECL -extern int shmdt P((SHM_ARG_TYPE *shaddr)); +extern int shmdt(SHM_ARG_TYPE *shaddr); #endif #ifndef HAVE_SHMGET_DECL -extern int shmget P((key_t key, size_t size, int shmflg)); +extern int shmget(key_t key, size_t size, int shmflg); #endif #endif -#if defined(HAVE_SNPRINTF) && defined(HAVE_VSNPRINTF) -#define ap_snprintf snprintf -#define ap_vsnprintf vsnprintf -#endif #ifndef HAVE_SNPRINTF_DECL #include "arglist.h" -int ap_snprintf P((char *buf, size_t len, const char *format,...)) - __attribute__((format(printf,3,4))); +int snprintf(char *buf, size_t len, const char *format,...) + G_GNUC_PRINTF(3,4); #endif #ifndef HAVE_VSNPRINTF_DECL #include "arglist.h" -int ap_vsnprintf P((char *buf, size_t len, const char *format, va_list ap)); +int vsnprintf(char *buf, size_t len, const char *format, va_list ap); #endif #ifndef HAVE_SOCKET_DECL -extern int socket P((int domain, int type, int protocol)); +extern int socket(int domain, int type, int protocol); #endif #ifndef HAVE_SOCKETPAIR_DECL -extern int socketpair P((int domain, int type, int protocol, int sv[2])); +extern int socketpair(int domain, int type, int protocol, int sv[2]); #endif #ifndef HAVE_SSCANF_DECL -extern int sscanf P((const char *s, const char *format, ...)); +extern int sscanf(const char *s, const char *format, ...); #endif #ifndef HAVE_STRCASECMP_DECL -extern int strcasecmp P((const char *s1, const char *s2)); +extern int strcasecmp(const char *s1, const char *s2); #endif #ifndef HAVE_STRERROR_DECL -extern char *strerror P((int errnum)); +extern char *strerror(int errnum); #endif #ifndef HAVE_STRFTIME_DECL -extern size_t strftime P((char *s, size_t maxsize, const char *format, - const struct tm *timeptr)); +extern size_t strftime(char *s, size_t maxsize, const char *format, + const struct tm *timeptr); #endif #ifndef HAVE_STRNCASECMP_DECL -extern int strncasecmp P((const char *s1, const char *s2, int n)); +extern int strncasecmp(const char *s1, const char *s2, int n); #endif #ifndef HAVE_SYSLOG_DECL -extern void syslog P((int priority, const char *logstring, ...)) - __attribute__ ((format (printf, 2, 3))); +extern void syslog(int priority, const char *logstring, ...) + G_GNUC_PRINTF(2,3); #endif #ifndef HAVE_SYSTEM_DECL -extern int system P((const char *string)); +extern int system(const char *string); #endif #ifndef HAVE_TIME_DECL -extern time_t time P((time_t *tloc)); +extern time_t time(time_t *tloc); #endif #ifndef HAVE_TOLOWER_DECL -extern int tolower P((int c)); +extern int tolower(int c); #endif #ifndef HAVE_TOUPPER_DECL -extern int toupper P((int c)); +extern int toupper(int c); #endif #ifndef HAVE_UNGETC_DECL -extern int ungetc P((int c, FILE *stream)); +extern int ungetc(int c, FILE *stream); #endif #ifndef HAVE_VFPRINTF_DECL #include "arglist.h" -extern int vfprintf P((FILE *stream, const char *format, va_list ap)); +extern int vfprintf(FILE *stream, const char *format, va_list ap); #endif #ifndef HAVE_VPRINTF_DECL #include "arglist.h" -extern int vprintf P((const char *format, va_list ap)); +extern int vprintf(const char *format, va_list ap); #endif +/* these system headers are added by gnulib if they + * do not exist */ +#include "netdb.h" +#include "arpa/inet.h" + +/* gnulib-only includes */ +#include "safe-read.h" +#include "full-read.h" +#include "full-write.h" + #if !defined(S_ISCHR) && defined(_S_IFCHR) && defined(_S_IFMT) #define S_ISCHR(mode) (((mode) & _S_IFMT) == _S_IFCHR) #endif @@ -1170,10 +1051,14 @@ extern int vprintf P((const char *format, va_list ap)); #ifdef HAVE_WAIT4 #define waitpid(pid,status,options) wait4(pid,status,options,0) #else -extern pid_t waitpid P((pid_t pid, amwait_t *stat_loc, int options)); +extern pid_t waitpid(pid_t pid, amwait_t *stat_loc, int options); #endif #endif +#ifndef HAVE_WRITEV_DECL +extern ssize_t writev(int fd, const struct iovec *iov, int iovcnt); +#endif + #ifndef STDIN_FILENO #define STDIN_FILENO 0 #endif @@ -1191,8 +1076,96 @@ extern pid_t waitpid P((pid_t pid, amwait_t *stat_loc, int options)); #if defined(_S_IFMT) && defined(_S_IFDIR) #define S_ISDIR(mode) (((mode) & (_S_IFMT)) == (_S_IFDIR)) #else -error: Don t know how to define S_ISDIR +#error Don t know how to define S_ISDIR +#endif +#endif + +#if SIZEOF_SIZE_T == SIZEOF_INT +# define SIZE_T_ATOI (size_t)atoi +# ifndef SIZE_MAX +# define SIZE_MAX G_MAXUINT +# endif +#else +# define SIZE_T_ATOI (size_t)atol +# ifndef SIZE_MAX +# define SIZE_MAX ULONG_MAX +# endif +#endif + +#if SIZEOF_SSIZE_T == SIZEOF_INT +# define SSIZE_T_ATOI (ssize_t)atoi +# ifndef SSIZE_MAX +# define SSIZE_MAX INT_MAX +# endif +# ifndef SSIZE_MIN +# define SSIZE_MIN INT_MIN +# endif +#else +# define SSIZE_T_ATOI (ssize_t)atol +# ifndef SSIZE_MAX +# define SSIZE_MAX LONG_MAX +# endif +# ifndef SSIZE_MIN +# define SSIZE_MIN LONG_MIN +# endif #endif + +#if SIZEOF_TIME_T == SIZEOF_INT +# define TIME_T_ATOI (time_t)atoi +# ifndef TIME_MAX +# define TIME_MAX G_MAXUINT +# endif +#else +# define TIME_T_ATOI (time_t)atol +# ifndef TIME_MAX +# define TIME_MAX ULONG_MAX +# endif #endif +#if SIZEOF_OFF_T > SIZEOF_LONG +# ifdef HAVE_ATOLL +# define OFF_T_ATOI (off_t)atoll +# else +# define OFF_T_ATOI (off_t)atol +# endif +# ifdef HAVE_STRTOLL +# define OFF_T_STRTOL (off_t)strtoll +# else +# define OFF_T_STRTOL (off_t)strtol +# endif +#else +# if SIZEOF_OFF_T == SIZEOF_LONG +# define OFF_T_ATOI (off_t)atol +# define OFF_T_STRTOL (off_t)strtol +# else +# define OFF_T_ATOI (off_t)atoi +# define OFF_T_STRTOL (off_t)strtol +# endif +#endif + + +#define BIND_CYCLE_RETRIES 120 /* Total of 30 minutes */ + +#define MAX_DUMPERS 63 + +#ifndef NI_MAXHOST +#define NI_MAXHOST 1025 +#endif + +typedef enum { + KENCRYPT_NONE, /* krb5 encryption not enabled */ + KENCRYPT_WILL_DO, /* krb5 encryption will be enabled once amanda + protocol stream is closed */ + KENCRYPT_YES /* krb5 encryption enabled on all stream */ +} kencrypt_type; + +#define DUMP_LEVELS 400 + +/* Constants to define the number of pre-opened pipes between amandad and + * its services */ + +/* If you change these (don't!), change them in perl/Amanda/Constants.pm, too */ +#define DATA_FD_COUNT 3 /* number of general-use pipes */ +#define DATA_FD_OFFSET 50 + #endif /* !AMANDA_H */