vfs: check userland buffers before reading them.
[haiku.git] / src / tests / kits / net / sock / ourhdr.h
blobfdd45be4f5bc6693bd37d4c2d915b54a4197ac35
1 /* -*- c-basic-offset: 8; -*- */
2 /* Our own header, to be included *after* all standard system headers */
4 #ifndef __ourhdr_h
5 #define __ourhdr_h
7 #include <sys/types.h> /* required for some of our prototypes */
8 #include <stdio.h> /* for convenience */
9 #include <stdlib.h> /* for convenience */
10 #include <string.h> /* for convenience */
11 #include <unistd.h> /* for convenience */
13 #ifdef notdef /* delete for systems that don't define this (SunOS 4.x) */
14 typedef int ssize_t;
15 #endif
17 #ifdef notdef /* delete if <stdlib.h> doesn't define these for getopt() */
18 extern char *optarg;
19 extern int optind, opterr, optopt;
20 #endif
22 #ifdef notdef /* delete if send() not supported (DEC OSF/1) */
23 #define send(a,b,c,d) sendto((a), (b), (c), (d), (struct sockaddr *) NULL, 0)
24 #endif
26 #define MAXLINE 4096 /* max line length */
28 #define FILE_MODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH)
29 /* default file access permissions for new files */
30 #define DIR_MODE (FILE_MODE | S_IXUSR | S_IXGRP | S_IXOTH)
31 /* default permissions for new directories */
33 typedef void Sigfunc(int); /* for signal handlers */
35 /* 4.3BSD Reno <signal.h> doesn't define SIG_ERR */
36 #if defined(SIG_IGN) && !defined(SIG_ERR)
37 #define SIG_ERR ((Sigfunc *)-1)
38 #endif
40 #define min(a,b) ((a) < (b) ? (a) : (b))
41 #define max(a,b) ((a) > (b) ? (a) : (b))
43 /* prototypes for our own functions */
44 char *path_alloc(int *); /* {Prog pathalloc} */
45 int open_max(void); /* {Prog openmax} */
46 void clr_fl(int, int); /* {Prog setfl} */
47 void set_fl(int, int); /* {Prog setfl} */
48 void pr_exit(int); /* {Prog prexit} */
49 void pr_mask(const char *); /* {Prog prmask} */
50 Sigfunc *signal_intr(int, Sigfunc *);/* {Prog signal_intr_function} */
52 int tty_cbreak(int); /* {Prog raw} */
53 int tty_raw(int); /* {Prog raw} */
54 int tty_reset(int); /* {Prog raw} */
55 void tty_atexit(void); /* {Prog raw} */
56 #ifdef ECHO /* only if <termios.h> has been included */
57 struct termios *tty_termios(void); /* {Prog raw} */
58 #endif
60 void sleep_us(unsigned int); /* {Ex sleepus} */
61 ssize_t readn(int, void *, size_t);/* {Prog readn} */
62 ssize_t writen(int, const void *, size_t);/* {Prog writen} */
63 int daemon_init(void); /* {Prog daemoninit} */
65 int s_pipe(int *); /* {Progs svr4_spipe bsd_spipe} */
66 int recv_fd(int, ssize_t (*func)(int, const void *, size_t));
67 /* {Progs recvfd_svr4 recvfd_43bsd} */
68 int send_fd(int, int); /* {Progs sendfd_svr4 sendfd_43bsd} */
69 int send_err(int, int, const char *);/* {Prog senderr} */
70 int serv_listen(const char *); /* {Progs servlisten_svr4 servlisten_44bsd} */
71 int serv_accept(int, uid_t *); /* {Progs servaccept_svr4 servaccept_44bsd} */
72 int cli_conn(const char *); /* {Progs cliconn_svr4 cliconn_44bsd} */
73 int buf_args(char *, int (*func)(int, char **));
74 /* {Prog bufargs} */
76 int ptym_open(char *); /* {Progs ptyopen_svr4 ptyopen_44bsd} */
77 int ptys_open(int, char *); /* {Progs ptyopen_svr4 ptyopen_44bsd} */
78 #ifdef TIOCGWINSZ
79 pid_t pty_fork(int *, char *, const struct termios *,
80 const struct winsize *); /* {Prog ptyfork} */
81 #endif
83 int lock_reg(int, int, int, off_t, int, off_t);
84 /* {Prog lockreg} */
85 #define read_lock(fd, offset, whence, len) \
86 lock_reg(fd, F_SETLK, F_RDLCK, offset, whence, len)
87 #define readw_lock(fd, offset, whence, len) \
88 lock_reg(fd, F_SETLKW, F_RDLCK, offset, whence, len)
89 #define write_lock(fd, offset, whence, len) \
90 lock_reg(fd, F_SETLK, F_WRLCK, offset, whence, len)
91 #define writew_lock(fd, offset, whence, len) \
92 lock_reg(fd, F_SETLKW, F_WRLCK, offset, whence, len)
93 #define un_lock(fd, offset, whence, len) \
94 lock_reg(fd, F_SETLK, F_UNLCK, offset, whence, len)
96 pid_t lock_test(int, int, off_t, int, off_t);
97 /* {Prog locktest} */
99 #define is_readlock(fd, offset, whence, len) \
100 lock_test(fd, F_RDLCK, offset, whence, len)
101 #define is_writelock(fd, offset, whence, len) \
102 lock_test(fd, F_WRLCK, offset, whence, len)
104 void err_dump(const char *, ...); /* {App misc_source} */
105 void err_msg(const char *, ...);
106 void err_quit(const char *, ...);
107 void err_ret(const char *, ...);
108 void err_sys(const char *, ...);
110 void log_msg(const char *, ...); /* {App misc_source} */
111 void log_open(const char *, int, int);
112 void log_quit(const char *, ...);
113 void log_ret(const char *, ...);
114 void log_sys(const char *, ...);
116 void TELL_WAIT(void); /* parent/child from {Sec race_conditions} */
117 void TELL_PARENT(pid_t);
118 void TELL_CHILD(pid_t);
119 void WAIT_PARENT(void);
120 void WAIT_CHILD(void);
122 #endif /* __ourhdr_h */