/*Our own header, to be included after all standard system headers*/<br />#ifndef __ourhdr_h<br />#define __ourhdr_h<br />#include <errno.h>/*for definition of errno */<br />#include <stdarg.h>/*ANSI C header file*/<br />#include <sys/types.h> /* required for some of our prototypes */<br />#include <stdio.h> /* for convenience */<br />#include <stdlib.h> /* for convenience */<br />#include <string.h> /* for convenience */<br />#include <unistd.h> /* for convenience */<br />#define MAXLINE 4096 /* max line length */<br />#define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)<br /> /* default file access permissions for new files */<br />#define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)<br /> /* default permissions for new directoris */<br />typedef void Sigfunc(int); /* for signal handlers */<br /> /* 4.3BSD Reno <signal.h> doesn't define<br />SIG_ERR */<br />#if defined(SIG_IGN) && !defined(SIG_ERR)<br />#define SIG_ERR ((Sigfunc *)-1)<br />#endif<br />#define min(a,b) ((a) < (b) ? (a) : (b))<br />#define max(a,b) ((a) > (b) ? (a) : (b))<br /> /* prototypes for our own functions */<br />char *path_alloc(int *); /* {Prog pathalloc} */<br />int open_max(void); /* {Prog openmax} */<br />void clr_fl(int, int); /* {Prog setfl} */<br />void set_fl(int, int); /* {Prog setfl} */<br />void pr_exit(int); /* {Prog prexit} */<br />void pr_mask(const char *); /* {Prog prmask} */<br />Sigfunc *signal_intr(int, Sigfunc *);/* {Prog signal_intr_function} */<br />int tty_cbreak(int); /* {Prog raw} */<br />int tty_raw(int); /* {Prog raw} */<br />int tty_reset(int); /* {Prog raw} */<br />void tty_atexit(void); /* {Prog raw} */<br />#ifdef ECHO /* only if <termios.h> has been included */<br />struct termios *tty_termios(void); /* {Prog raw} */<br />#endif<br />void sleep_us(unsigned int); /* {Ex sleepus} */<br />ssize_t readn(int, void *, size_t);/* {Prog readn} */<br />ssize_t writen(int, const void *, size_t);/* {Prog writen} */<br />int daemon_init(void); /* {Prog daemoninit} */<br />int s_pipe(int *); /* {Progs svr4_spipe bsd spipe} */<br />int recv_fd(int, ssize_t (*func)(int, const void *, size_t));<br /> /* {Prog recvfd_svr4 recvfd_43bsd} */<br />int send_fd(int, int); /* {Progs sendfd_svr4 se dfd_43bsd} */<br />int send_err(int, int, const char *);/* {Prog senderr} */<br />int serv_listen(const char *); /* {Progs servlisten_svr4 servli ten_4 4bsd} */<br />int serv_accept(int, uid_t *); /* {Progs servaccept_svr4 servac ept_4 4bsd} */<br />int cli_conn(const char *); /* {Progs cliconn_svr4 cliconn_4 bsd} */<br />int buf_args(char *, int (*func)(int, char **));<br /> /* {Prog bufargs} */<br />int ptym_open(char *); /* {Progs ptyopen_svr4 p yopen_44bsd} */<br />int ptys_open(int, char *); /* {Progs ptyopen_svr4 ptyopen_4 bsd} */<br />#ifdef TIOCGWINSZ<br />pid_t pty_fork(int *, char *, const struct termios *,<br /> const struct winsize *); /* {Prog ptyfork */<br />#endif<br />int lock_reg(int, int, int, off_t, int, off_t);<br /> /* {Prog lockreg} */<br />#define read_lock(fd, offset, whence, len) lock_reg(fd, F_SETLK, F_RDLCK, offset, whence, len)<br />#define readw_lock(fd, offset, whence, len) lock_reg(fd, F_SETLKW, F_RDLCK, offset, whence, len)<br />#define write_lock(fd, offset, whence, len) lock_reg(fd, F_SETLK, F_WRLCK, offset, whence, len)<br />#define writew_lock(fd, offset, whence, len) lock_reg(fd, F_SETLKW, F_WRLCK, offset, whence, len)<br />#define un_lock(fd, offset, whence, len) lock_reg(fd, F_SETLK, F_UNLCK, offset, whence, len)<br />pid_t lock_test(int, int, off_t, int, off_t);<br /> /* {Prog locktest} */<br />#define is_readlock(fd, offset, whence, len) lock_test(fd, F_RDLCK, offset, whence, len)<br />#define is_writelock(fd, offset, whence, len) lock_test(fd, F_WRLCK, offset, whence, len)<br />void err_dump(const char *, ...); /* {App misc_source} */<br />void err_msg(const char *, ...);<br />void err_quit(const char *, ...);<br />void err_ret(const char *, ...);<br />void err_sys(const char *, ...);<br />void log_msg(const char *, ...); /* {App misc_source} */<br />void log_open(const char *, int, int);<br />void log_quit(const char *, ...);<br />void log_ret(const char *, ...);<br />void log_sys(const char *, ...);<br />void TELL_WAIT(void); /* parent/child from {Sec race_condition } */<br />void TELL_PARENT(pid_t);<br />void TELL_CHILD(pid_t);<br />void WAIT_PARENT(void);<br />void WAIT_CHILD(void);<br />#endif /* __ourhdr_h */