/*
* Copyright (c) 1997-2014 Erez Zadok
* Copyright (c) 1990 Jan-Simon Pendry
* Copyright (c) 1990 Imperial College of Science, Technology & Medicine
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
*
* This code is derived from software contributed to Berkeley by
* Jan-Simon Pendry at Imperial College, London.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
*
* File: am-utils/include/am_utils.h
*
*/
/*
* Definitions that are specific to the am-utils package.
*/
/*
* General macros.
*/
#ifndef FALSE
# define FALSE 0
#endif /* not FALSE */
#ifndef TRUE
# define TRUE 1
#endif /* not TRUE */
#ifndef MAX
# define MAX(a, b) ((a) > (b) ? (a) : (b))
#endif /* not MAX */
#ifndef MIN
# define MIN(a, b) ((a) < (b) ? (a) : (b))
#endif /* not MIN */
#define ONE_HOUR (60 * 60) /* One hour in seconds */
#ifndef MAXHOSTNAMELEN
# ifdef HOSTNAMESZ
# define MAXHOSTNAMELEN HOSTNAMESZ
# else /* not HOSTNAMESZ */
# define MAXHOSTNAMELEN 256
# endif /* not HOSTNAMESZ */
#endif /* not MAXHOSTNAMELEN */
/*
* for hlfsd, and amd for detecting uid/gid
*/
#ifndef INVALIDID
/* this is also defined in include/am_utils.h */
# define INVALIDID (((unsigned short) ~0) - 3)
#endif /* not INVALIDID */
#define NO_SUBNET "notknown" /* default subnet name for no subnet */
#define NEXP_AP (1022) /* gdmr: was 254 */
#define NEXP_AP_MARGIN (128) /* ???? not used */
/* allocate anything of type ty */
#define ALLOC(ty) ((ty *) xmalloc(sizeof(ty)))
#define CALLOC(ty) ((ty *) xzalloc(sizeof(ty)))
/* simply allocate b bytes */
#define SALLOC(b) xmalloc((b))
/*
* Systems which have the mount table in a file need to read it before
* they can perform an unmount() system call.
*/
#define UMOUNT_FS(dir, mtb_name, unmount_flags) umount_fs(dir, mtb_name, unmount_flags)
/* next two are imported via $srcdir/conf/umount/umount_*.c */
extern int umount_fs(char *mntdir, const char *mnttabname, u_int unmount_flags);
#ifdef MNT2_GEN_OPT_FORCE
extern int umount2_fs(const char *mntdir, u_int unmount_flags);
#endif /* MNT2_GEN_OPT_FORCE */
/*
* What level of AMD are we backward compatible with?
* This only applies to externally visible characteristics.
* Rev.Minor.Branch.Patch (2 digits each)
*/
#define AMD_COMPAT 5000000 /* 5.0 */
/**************************************************************************/
/*** STRUCTURES AND TYPEDEFS ***/
/**************************************************************************/
/* some typedefs must come first */
typedef char *amq_string;
typedef struct _qelem qelem;
typedef struct mntlist mntlist;
/*
* Linked list
* (the name 'struct qelem' conflicts with linux's unistd.h)
*/
struct _qelem {
qelem *q_forw;
qelem *q_back;
};
extern int foreground; /* Foreground process */
extern int orig_umask; /* umask() on startup */
extern serv_state amd_state; /* Should we go now */
extern struct in_addr myipaddr; /* (An) IP address of this host */
extern struct opt_tab xlog_opt[];
extern u_short nfs_port; /* Our NFS service port */
/* my favorite debugging tool -Erez */
#define EZKDBG plog(XLOG_INFO,"EZK:%s:%s:%d\n",__FILE__,__FUNCTION__,__LINE__)
# ifdef DEBUG_MEM
/*
* If debugging memory, then call a special freeing function that logs
* more info, and resets the pointer to NULL so it cannot be used again.
*/
# define XFREE(x) dxfree(__FILE__,__LINE__,x)
extern void dxfree(char *file, int line, voidp ptr);
extern void malloc_verify(void);
# else /* not DEBUG_MEM */
/*
* If regular debugging, then free the pointer and reset to NULL.
* This should remain so for as long as am-utils is in alpha/beta testing.
*/
# define XFREE(x) do { free((voidp)x); x = NULL;} while (0)
# endif /* not DEBUG_MEM */
/**************************************************************************/
/*** MISC (stuff left to autoconfiscate) ***/
/**************************************************************************/