vx32

Local 9vx git repository for patches.
git clone git://r-36.net/vx32
Log | Files | Refs

lib.h (3824B)


      1 /*
      2  * functions (possibly) linked in, complete, from libc.
      3  */
      4 #define nelem(x)	(sizeof(x)/sizeof((x)[0]))
      5 #define offsetof(s, m)	(ulong)(&(((s*)0)->m))
      6 
      7 /*
      8  * mem routines
      9  */
     10 
     11 /*
     12  * string routines
     13  */
     14 extern	char*	strecpy(char*, char*, char*);
     15 
     16 
     17 
     18 /*
     19  * one-of-a-kind
     20  */
     21 extern	char*	cleanname(char*);
     22 extern	ulong	getcallerpc(void*);
     23 
     24 extern	int	getfields(char*, char**, int, int, char*);
     25 extern	int	gettokens(char *, char **, int , char *);
     26 extern	int	tokenize(char*, char**, int);
     27 extern	int	dec64(uchar*, int, char*, int);
     28 
     29 /*
     30  * Syscall data structures
     31  */
     32 #define	MORDER	0x0003	/* mask for bits defining order of mounting */
     33 #define	MREPL	0x0000	/* mount replaces object */
     34 #define	MBEFORE	0x0001	/* mount goes before others in union directory */
     35 #define	MAFTER	0x0002	/* mount goes after others in union directory */
     36 #define	MCREATE	0x0004	/* permit creation in mounted directory */
     37 #define	MCACHE	0x0010	/* cache some data */
     38 #define	MMASK	0x0017	/* all bits on */
     39 
     40 #define	OREAD	0	/* open for read */
     41 #define	OWRITE	1	/* write */
     42 #define	ORDWR	2	/* read and write */
     43 #define	OEXEC	3	/* execute, == read but check execute permission */
     44 #define	OTRUNC	16	/* or'ed in (except for exec), truncate file first */
     45 #define	OCEXEC	32	/* or'ed in, close on exec */
     46 #define	ORCLOSE	64	/* or'ed in, remove on close */
     47 #define OEXCL   0x1000	/* or'ed in, exclusive create */
     48 
     49 #define	NCONT	0	/* continue after note */
     50 #define	NDFLT	1	/* terminate after note */
     51 #define	NSAVE	2	/* clear note but hold state */
     52 #define	NRSTR	3	/* restore saved state */
     53 
     54 typedef struct Qid	Qid;
     55 typedef struct Dir	Dir;
     56 typedef struct OWaitmsg	OWaitmsg;
     57 typedef struct Waitmsg	Waitmsg;
     58 
     59 #define	ERRMAX			128	/* max length of error string */
     60 #define	KNAMELEN		28	/* max length of name held in kernel */
     61 
     62 /* bits in Qid.type */
     63 #define QTDIR		0x80		/* type bit for directories */
     64 #define QTAPPEND	0x40		/* type bit for append only files */
     65 #define QTEXCL		0x20		/* type bit for exclusive use files */
     66 #define QTMOUNT		0x10		/* type bit for mounted channel */
     67 #define QTAUTH		0x08		/* type bit for authentication file */
     68 #define QTFILE		0x00		/* plain file */
     69 
     70 /* bits in Dir.mode */
     71 #define DMDIR		0x80000000	/* mode bit for directories */
     72 #define DMAPPEND	0x40000000	/* mode bit for append only files */
     73 #define DMEXCL		0x20000000	/* mode bit for exclusive use files */
     74 #define DMMOUNT		0x10000000	/* mode bit for mounted channel */
     75 #define DMREAD		0x4		/* mode bit for read permission */
     76 #define DMWRITE		0x2		/* mode bit for write permission */
     77 #define DMEXEC		0x1		/* mode bit for execute permission */
     78 
     79 struct Qid
     80 {
     81 	uvlong	path;
     82 	ulong	vers;
     83 	uchar	type;
     84 };
     85 
     86 struct Dir {
     87 	/* system-modified data */
     88 	ushort	type;	/* server type */
     89 	uint	dev;	/* server subtype */
     90 	/* file data */
     91 	Qid	qid;	/* unique id from server */
     92 	ulong	mode;	/* permissions */
     93 	ulong	atime;	/* last read time */
     94 	ulong	mtime;	/* last write time */
     95 	vlong	length;	/* file length: see <u.h> */
     96 	char	*name;	/* last element of path */
     97 	char	*uid;	/* owner name */
     98 	char	*gid;	/* group name */
     99 	char	*muid;	/* last modifier name */
    100 };
    101 
    102 struct OWaitmsg
    103 {
    104 	char	pid[12];	/* of loved one */
    105 	char	time[3*12];	/* of loved one and descendants */
    106 	char	msg[64];	/* compatibility BUG */
    107 };
    108 
    109 struct Waitmsg
    110 {
    111 	int	pid;		/* of loved one */
    112 	ulong	time[3];	/* of loved one and descendants */
    113 	char	msg[ERRMAX];	/* actually variable-size in user mode */
    114 };
    115 
    116 #include "utf.h"
    117 #include "fmt.h"
    118 
    119 extern	int	dec64(uchar*, int, char*, int);
    120 extern	int	enc64(char*, int, uchar*, int);
    121 extern	int	dec32(uchar*, int, char*, int);
    122 extern	int	enc32(char*, int, uchar*, int);
    123 extern	int	dec16(uchar*, int, char*, int);
    124 extern	int	enc16(char*, int, uchar*, int);
    125 extern	int	encodefmt(Fmt*);
    126 extern	int	fmtstrcpy(Fmt*, char*);
    127 
    128 extern	void*	mallocz(ulong, int);
    129 extern	void	werrstr(char*, ...);
    130