⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 amanda.h

📁 开源备份软件源码 AMANDA, the Advanced Maryland Automatic Network Disk Archiver, is a backup system that a
💻 H
📖 第 1 页 / 共 3 页
字号:
#define MAX_TAPE_LABEL_LEN (10240)#define MAX_TAPE_LABEL_BUF (MAX_TAPE_LABEL_LEN+1)#define MAX_TAPE_LABEL_FMT "%10240s"#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__)#define	stralloc2(s1,s2)	vstralloc((s1),(s2),NULL)#define	newstralloc2(p,s1,s2)	newvstralloc((p),(s1),(s2),NULL)#define vstrallocf(...)         debug_vstrallocf(__FILE__,__LINE__,__VA_ARGS__)/*@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(const char *file,				  int line,				  void **table,				  size_t *current,				  size_t elsize,				  size_t 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(void **, size_t *);char **	safe_env(void);char *	validate_regexp(const char *regex);char *	validate_glob(const char *glob);char *	clean_regex(const char *regex);int	match(const char *regex, const char *str);int	match_glob(const char *glob, const char *str);char *	glob_to_regex(const char *glob);int	match_tar(const char *glob, const char *str);char *	tar_to_regex(const char *glob);int	match_host(const char *glob, const char *host);int	match_disk(const char *glob, const char *disk);int	match_datestamp(const char *dateexp, const char *datestamp);int	match_level(const char *levelexp, const char *level);time_t	unctime(char *timestr);/* * amfree(ptr) -- if allocated, release space and set ptr to NULL. * * In general, this should be called instead of just free(), unless * the very next source line sets the pointer to a new value. */#define	amfree(ptr) do {						\    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)#define strappend(s1,s2) do {						\    char *t_t_t = (s1) ? stralloc2((s1),(s2)) : stralloc((s2));		\    amfree((s1));							\    (s1) = t_t_t;							\} while(0)/* * Return the number of elements in an array. */#define am_countof(a)	(int)(SIZEOF(a) / SIZEOF((a)[0]))/* * min/max.  Don't do something like * *    x = min(y++, z); * * because the increment will be duplicated. */#undef min#undef max#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 * character and the string pointer points to the next character to * be processed.  Typical setup is: * *  s = buffer; *  ch = *s++; *  skip_whitespace(s, ch); *  ... * * If you advance the pointer "by hand" to skip over something, do * it like this: * *  s += some_amount; *  ch = s[-1]; * * Note that ch has the character at the end of the just skipped field. * It is often useful to terminate a string, make a copy, then restore * the input like this: * *  skip_whitespace(s, ch); *  fp = s-1;			## save the start *  skip_nonwhitespace(s, ch);	## find the end *  p[-1] = '\0';		## temporary terminate *  field = stralloc(fp);	## make a copy *  p[-1] = ch;			## restore the input * * The scanning macros are: * *  skip_whitespace (ptr, var) *    -- skip whitespace, but stops at a newline *  skip_non_whitespace (ptr, var) *    -- skip non whitespace *  skip_non_whitespace_cs (ptr, var) *    -- skip non whitespace, stop at comment *  skip_integer (ptr, var) *    -- 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: * *  ptr -- string pointer *  var -- current character * * These macros copy a non-whitespace field to a new buffer, and should * only be used if dynamic allocation is impossible (fixed size buffers * are asking for trouble): * *  copy_string (ptr, var, field, len, fldptr) *    -- copy a non-whitespace field *  copy_string_cs (ptr, var, field, len, fldptr) *    -- copy a non-whitespace field, stop at comment * * where: * *  ptr -- string pointer *  var -- current character *  field -- area to copy to *  len -- length of area (needs room for null byte) *  fldptr -- work pointer used in move *	      if NULL on exit, the field was too small for the input */#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((int)c)) (c) = *(ptr)++;		\} while(0)#define	skip_non_whitespace(ptr,c) do {					\    while((c) != '\0' && !isspace((int)c)) (c) = *(ptr)++;		\} while(0)#define	skip_non_whitespace_cs(ptr,c) do {				\    while((c) != '\0' && (c) != '#' && !isspace((int)c)) (c) = *(ptr)++;\} while(0)#define	skip_non_integer(ptr,c) do {					\    while((c) != '\0' && !isdigit(c)) (c) = *(ptr)++;			\} while(0)#define	skip_integer(ptr,c) do {					\    if((c) == '+' || (c) == '-') (c) = *(ptr)++;			\    while(isdigit(c)) (c) = *(ptr)++;					\} while(0)#define skip_quoted_string(ptr, c) do {					\    int	iq = 0;								\    while (((c) != '\0') && !((iq == 0) && isspace((int)c))) {		\	if ((c) == '"') {						\	    iq = !iq;							\	} else if (((c) == '\\') && (*(ptr) == '"')) {			\	    (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(0)#define	copy_string(ptr,c,f,l,fp) do {					\    (fp) = (f);								\    while((c) != '\0' && !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';							\} while(0)#define	copy_string_cs(ptr,c,f,l,fp) do {				\    (fp) = (f);								\    while((c) != '\0' && (c) != '#' && !isspace((int)c)) {		\	if((fp) >= (f) + (l) - 1) {					\	    *(fp) = '\0';						\	    (fp) = NULL;						\	    break;							\	}								\	*(fp)++ = (c);							\	(c) = *(ptr)++;							\    }									\    if(fp) *fp = '\0';							\} while(0)#define is_dot_or_dotdot(s)						\    ((s)[0] == '.'							\     && ((s)[1] == '\0'							\	 || ((s)[1] == '.' && (s)[2] == '\0')))#define strncmp_const(str, cnst)					\	strncmp((str), (cnst), sizeof((cnst))-1)/* (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 int check_security(struct sockaddr_storage *, char *, unsigned long, char **);/* * Handle functions which are not always declared on all systems.  This * stops gcc -Wall and lint from complaining. *//* AIX #defines accept, and provides a prototype for the alternate name */#if !defined(HAVE_ACCEPT_DECL) && !defined(accept)extern int accept(int s, struct sockaddr *addr, socklen_t *addrlen);#endif#ifndef HAVE_ATOF_DECLextern double atof(const char *ptr);#endif#ifndef HAVE_BCOPY# define bcopy(from,to,n) ((void)memmove((to), (from), (n)))#else# ifndef HAVE_BCOPY_DECLextern void bcopy(const void *s1, void *s2, size_t n);# endif#endif#ifndef HAVE_BIND_DECLextern int bind(int s, const struct sockaddr *name, socklen_t namelen);#endif#ifndef HAVE_BZERO#define bzero(s,n) ((void)memset((s),0,(n)))#else# ifndef HAVE_BZERO_DECLextern void bzero(void *s, size_t n);# endif#endif#ifndef HAVE_CLOSELOG_DECLextern void closelog(void);#endif#ifndef HAVE_CONNECT_DECLextern int connect(int s, struct sockaddr *name, socklen_t namelen);#endif#ifndef HAVE_FCLOSE_DECLextern int fclose(FILE *stream);#endif#ifndef HAVE_FFLUSH_DECLextern int fflush(FILE *stream);#endif#ifndef HAVE_FPRINTF_DECLextern int fprintf(FILE *stream, const char *format, ...);#endif#ifndef HAVE_FPUTC_DECLextern int fputc(int c, FILE *stream);#endif#ifndef HAVE_FPUTS_DECLextern int fputs(const char *s, FILE *stream);#endif#ifndef HAVE_FREAD_DECLextern size_t fread(void *ptr, size_t size, size_t nitems, FILE *stream);#endif#ifndef HAVE_FSEEK_DECLextern int fseek(FILE *stream, long offset, int ptrname);#endif#ifndef HAVE_FWRITE_DECLextern size_t fwrite(const void *ptr, size_t size, size_t nitems,			FILE *stream);#endif#ifndef HAVE_GETHOSTNAME_DECLextern int gethostname(char *name, int namelen);#endif#ifndef HAVE_GETOPT_DECLextern char *optarg;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(int s, struct sockaddr *name, socklen_t *namelen);#endif/* AIX #defines getsockname, and provides a prototype for the alternate name */#if !defined(HAVE_GETSOCKNAME_DECL) && !defined(getsockname)extern int getsockname(int s, struct sockaddr *name, socklen_t *namelen);#endif#ifndef HAVE_GETSOCKOPT_DECLextern int getsockopt(int s, int level, int optname, char *optval,			 socklen_t *optlen);#endif#ifndef HAVE_INITGROUPS# define initgroups(name,basegid) 0#else# ifndef HAVE_INITGROUPS_DECLextern int initgroups(const char *name, gid_t basegid);# endif#endif#ifndef HAVE_IOCTL_DECLextern 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_DECLextern int listen(int s, int backlog);#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -