#ifndef SYSDEP_H
#define SYSDEP_H
#if ANSI_C
struct uuconf_system;
struct sconnection;
#endif
#if HAVE_SCO_LOCKFILES || HAVE_SVR4_LOCKFILES || HAVE_SEQUENT_LOCKFILES
#undef HAVE_HDB_LOCKFILES
#define HAVE_HDB_LOCKFILES 1
#endif
#if HAVE_BSD_TTY + HAVE_SYSV_TERMIO + HAVE_POSIX_TERMIOS != 1
#error Terminal driver define not set or duplicated
#endif
#if SPOOLDIR_V2 + SPOOLDIR_BSD42 + SPOOLDIR_BSD43 + SPOOLDIR_HDB + SPOOLDIR_ULTRIX + SPOOLDIR_SVR4 + SPOOLDIR_TAYLOR != 1
#error Spool directory define not set or duplicated
#endif
#if HAVE_BROKEN_SETREUID
#undef HAVE_SETREUID
#define HAVE_SETREUID 0
#endif
#ifdef PID_T
typedef PID_T pid_t;
#endif
#ifdef UID_T
typedef UID_T uid_t;
#endif
#ifdef GID_T
typedef GID_T gid_t;
#endif
#ifdef OFF_T
typedef OFF_T off_t;
#endif
#define BINREAD "r"
#define BINWRITE "w"
#if HAVE_SIGACTION
#undef HAVE_RESTARTABLE_SYSCALLS
#define HAVE_RESTARTABLE_SYSCALLS 0
#endif
#if HAVE_SIGVEC && HAVE_SIGVEC_SV_FLAGS
#ifdef SV_INTERRUPT
#undef HAVE_RESTARTABLE_SYSCALLS
#define HAVE_RESTARTABLE_SYSCALLS 0
#endif
#endif
#if HAVE_RESTARTABLE_SYSCALLS == -1
#undef HAVE_RESTARTABLE_SYSCALLS
#if HAVE_SIGVEC
#define HAVE_RESTARTABLE_SYSCALLS 1
#else
#define HAVE_RESTARTABLE_SYSCALLS 0
#endif
#endif
#if ! HAVE_SIGACTION && ! HAVE_SIGVEC && HAVE_SIGSET
#if HAVE_RESTARTABLE_SYSCALLS
#undef HAVE_SIGSET
#define HAVE_SIGSET 0
#endif
#endif
#if ! HAVE_RESTARTABLE_SYSCALLS
#define fsysdep_catch() (TRUE)
#define usysdep_start_catch()
#define usysdep_end_catch()
#define CATCH_PROTECT
#else
#if HAVE_SETRET && ! HAVE_SIGSETJMP
#include <setret.h>
#define setjmp setret
#define longjmp longret
#define jmp_buf ret_buf
#else
#include <setjmp.h>
#if HAVE_SIGSETJMP
#undef setjmp
#undef longjmp
#undef jmp_buf
#define setjmp(s) sigsetjmp ((s), TRUE)
#define longjmp siglongjmp
#define jmp_buf sigjmp_buf
#endif
#endif
extern volatile sig_atomic_t fSjmp;
extern volatile jmp_buf sSjmp_buf;
#define fsysdep_catch() (setjmp (sSjmp_buf) == 0)
#define usysdep_start_catch() (fSjmp = TRUE)
#define usysdep_end_catch() (fSjmp = FALSE)
#define CATCH_PROTECT volatile
#endif
#if HAVE_BSD_TTY
#include <sgtty.h>
struct sbsd_terminal
{
struct sgttyb stty;
struct tchars stchars;
struct ltchars sltchars;
};
typedef struct sbsd_terminal sterminal;
#define fgetterminfo(o, q) \
(ioctl ((o), TIOCGETP, &(q)->stty) == 0 \
&& ioctl ((o), TIOCGETC, &(q)->stchars) == 0 \
&& ioctl ((o), TIOCGLTC, &(q)->sltchars) == 0)
#define fsetterminfo(o, q) \
(ioctl ((o), TIOCSETN, &(q)->stty) == 0 \
&& ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
&& ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
#define fsetterminfodrain(o, q) \
(ioctl ((o), TIOCSETP, &(q)->stty) == 0 \
&& ioctl ((o), TIOCSETC, &(q)->stchars) == 0 \
&& ioctl ((o), TIOCSLTC, &(q)->sltchars) == 0)
#endif
#if HAVE_SYSV_TERMIO
#include <termio.h>
typedef struct termio sterminal;
#define fgetterminfo(o, q) (ioctl ((o), TCGETA, (q)) == 0)
#define fsetterminfo(o, q) (ioctl ((o), TCSETA, (q)) == 0)
#define fsetterminfodrain(o, q) (ioctl ((o), TCSETAW, (q)) == 0)
#endif
#if HAVE_POSIX_TERMIOS
#include <termios.h>
typedef struct termios sterminal;
#define fgetterminfo(o, q) (tcgetattr ((o), (q)) == 0)
#define fsetterminfo(o, q) (tcsetattr ((o), TCSANOW, (q)) == 0)
#define fsetterminfodrain(o, q) (tcsetattr ((o), TCSADRAIN, (q)) == 0)
#if ! HAVE_TERMIOS_AND_SYS_IOCTL_H
#undef HAVE_SYS_IOCTL_H
#define HAVE_SYS_IOCTL_H 0
#endif
#endif
#define ZROOTDIR "/"
#define XQTDIR ".Xqtdir"
#define PRESERVEDIR ".Preserve"
#define CORRUPTDIR ".Corrupt"
#define FAILEDDIR ".Failed"
#define CSEQLEN (4)
#if USE_STDIO && HAVE_UNISTD_H
#include <unistd.h>
#endif
#if ! USE_TYPES_H
#include <sys/types.h>
#endif
#include <sys/stat.h>
#ifndef S_IRWXU
#define S_IRWXU 0700
#endif
#ifndef S_IRUSR
#define S_IRUSR 0400
#endif
#ifndef S_IWUSR
#define S_IWUSR 0200
#endif
#ifndef S_IXUSR
#define S_IXUSR 0100
#endif
#ifndef S_IRWXG
#define S_IRWXG 0070
#endif
#ifndef S_IRGRP
#define S_IRGRP 0040
#endif
#ifndef S_IWGRP
#define S_IWGRP 0020
#endif
#ifndef S_IXGRP
#define S_IXGRP 0010
#endif
#ifndef S_IRWXO
#define S_IRWXO 0007
#endif
#ifndef S_IROTH
#define S_IROTH 0004
#endif
#ifndef S_IWOTH
#define S_IWOTH 0002
#endif
#ifndef S_IXOTH
#define S_IXOTH 0001
#endif
#if STAT_MACROS_BROKEN
#undef S_ISDIR
#endif
#ifndef S_ISDIR
#ifdef S_IFDIR
#define S_ISDIR(i) (((i) & S_IFMT) == S_IFDIR)
#else
#define S_ISDIR(i) (((i) & 0170000) == 040000)
#endif
#endif
#ifndef R_OK
#define R_OK 4
#define W_OK 2
#define X_OK 1
#define F_OK 0
#endif
#define IPRIVATE_FILE_MODE (S_IRUSR | S_IWUSR)
#define IPUBLIC_FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
#define IDIRECTORY_MODE (S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH)
#define IPUBLIC_DIRECTORY_MODE (S_IRWXU | S_IRWXG | S_IRWXO)
#if ! HAVE_OPENDIR
#include <sys/dir.h>
struct dirent
{
char d_name[DIRSIZ + 1];
};
typedef struct
{
int o;
struct dirent s;
} DIR;
extern DIR *opendir P((const char *zdir));
extern struct dirent *readdir P((DIR *));
extern int closedir P((DIR *));
#endif
#if ! HAVE_FTW_H
#define FTW_F (0)
#define FTW_D (1)
#define FTW_DNR (2)
#define FTW_NS (3)
#endif
struct ssysdep_conn
{
int o;
int ord;
int owr;
char *zdevice;
int iflags;
int iwr_flags;
int ohold;
boolean fterminal;
boolean ftli;
long ibaud;
sterminal sorig;
sterminal snew;
pid_t ipid;
#if HAVE_COHERENT_LOCKFILES
char *zenable;
#endif
};
extern boolean fsysdep_conn_read P((struct sconnection *qconn,
char *zbuf, size_t *pclen,
size_t cmin, int ctimeout,
boolean freport));
extern boolean fsysdep_conn_write P((struct sconnection *qconn,
const char *zbuf, size_t clen));
extern boolean fsysdep_conn_io P((struct sconnection *qconn,
const char *zwrite, size_t *pcwrite,
char *zread, size_t *pcread));
extern boolean fsysdep_conn_chat P((struct sconnection *qconn,
char **pzprog));
extern void usset_signal P((int isig, RETSIGTYPE (*pfn) P((int)),
boolean fforce, boolean *pfignored));
extern RETSIGTYPE ussignal P((int isig));
extern pid_t ixsfork P((void));
#define SPAWN_NULL (-1)
#define SPAWN_READ_PIPE (-2)
#define SPAWN_WRITE_PIPE (-3)
extern pid_t ixsspawn P((const char **pazargs, int *aidescs,
boolean fkeepuid, boolean fkeepenv,
const char *zchdir, boolean fnosigs,
boolean fshell, const char *zpath,
const char *zuu_machine,
const char *zuu_user));
extern FILE *espopen P((const char **pazargs, boolean frd,
pid_t *pipid));
extern int ixswait P((unsigned long ipid, const char *zreport));
extern boolean fsdouble_read P((struct sconnection *qconn, char *zbuf,
size_t *pclen, size_t cmin, int ctimeout,
boolean freport));
extern boolean fsdouble_write P((struct sconnection *qconn,
const char *zbuf, size_t clen));
extern boolean fsdouble_chat P((struct sconnection *qconn,
char **pzprog));
extern char *zsfind_file P((const char *zsimple, const char *zsystem,
int bgrade));
extern int bsgrade P((pointer pseq));
extern boolean fsdo_lock P((const char *, boolean fspooldir,
boolean *pferr));
extern boolean fsdo_unlock P((const char *, boolean fspooldir));
extern boolean fsuser_access P((const struct stat *, int imode,
const char *zuser));
extern boolean fsuser_perms P((uid_t *, gid_t *));
extern boolean fsuucp_perms P((long, long));
extern char *zsappend3 P((const char *zdir1, const char *zdir2,
const char *zfile));
extern char *zsappend4 P((const char *zdir1, const char *zdir2,
const char *zdir3, const char *zfile));
extern char *zstemp_file P((const struct uuconf_system *qsys));
extern char *zscmd_file P((const struct uuconf_system *qsys, int bgrade));
extern char *zsfile_to_jobid P((const struct uuconf_system *qsys,
const char *zfile,
int bgrade));
extern char *zsjobid_to_file P((const char *zid, char **pzsystem,
char *pbgrade));
extern boolean fsultrix_has_spool P((const char *zsystem));
#if HAVE_COHERENT_LOCKFILES
extern boolean lockttyexist P((const char *z));
extern boolean fscoherent_disable_tty P((const char *zdevice,
char **pzenable));
#endif
#if ! HAVE_DUP2
extern int dup2 P((int oold, int onew));
#endif
#if ! HAVE_FTW
extern int ftw P((const char *zdir,
int (*pfn) P((const char *zfile,
const struct stat *qstat,
int iflag)),
int cdescriptors));
#endif
#if ! HAVE_GETCWD && ! HAVE_GETWD
extern char *getcwd P((char *zbuf, size_t cbuf));
#endif
#if ! HAVE_MKDIR
extern int mkdir P((const char *zdir, int imode));
#endif
#if ! HAVE_RENAME
extern int rename P((const char *zold, const char *znew));
#endif
#if ! HAVE_RMDIR
extern int rmdir P((const char *zdir));
#endif
extern char *zScwd;
extern const char *zSspooldir;
extern const char *zSlockdir;
extern const char *zSlocalname;
#endif