Initial import from FreeBSD RELENG_4:
[dragonfly.git] / usr.bin / truss / syscall.h
1 /*
2  * See i386-fbsd.c for copyright and license terms.
3  *
4  * System call arguments come in several flavours:
5  * Hex -- values that should be printed in hex (addresses)
6  * Octal -- Same as above, but octal
7  * Int -- normal integer values (file descriptors, for example)
8  * String -- pointers to sensible data.  Note that we treat read() and
9  *      write() arguments as such, even though they may *not* be
10  *      printable data.
11  * Ptr -- pointer to some specific structure.  Just print as hex for now.
12  * Quad -- a double-word value.  e.g., lseek(int, offset_t, int)
13  * Stat -- a pointer to a stat buffer.  Currently unused.
14  * Ioctl -- an ioctl command.  Woefully limited.
15  *
16  * In addition, the pointer types (String, Ptr) may have OUT masked in --
17  * this means that the data is set on *return* from the system call -- or
18  * IN (meaning that the data is passed *into* the system call).
19  */
20 /*
21  * $FreeBSD: src/usr.bin/truss/syscall.h,v 1.5.2.3 2002/02/15 11:43:51 des Exp $
22  */
23
24 enum Argtype { None = 1, Hex, Octal, Int, String, Ptr, Stat, Ioctl, Quad,
25         Signal, Sockaddr };
26
27 #define ARG_MASK        0xff
28 #define OUT     0x100
29 #define IN      /*0x20*/0
30
31 struct syscall_args {
32         enum Argtype type;
33         int offset;
34 };
35
36 struct syscall {
37         const char *name;
38         int ret_type;   /* 0, 1, or 2 return values */
39         int nargs;      /* actual number of meaningful arguments */
40                         /* Hopefully, no syscalls with > 10 args */
41         struct syscall_args args[10];
42 };
43
44 struct syscall *get_syscall(const char*);
45 char *get_string(int, void*, int);
46 char *print_arg(int, struct syscall_args *, unsigned long*);
47 void print_syscall(FILE *, const char *, int, char **);
48 void print_syscall_ret(FILE *, const char *, int, char **, int, int);