lib9.h 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #ifndef __LIB9_H
  2. #define __LIB9_H
  3. #if !defined(_RESEARCH_SOURCE) && !defined(_PLAN9_SOURCE)
  4. This header file is an extension to ANSI/POSIX
  5. #endif
  6. #pragma lib "/$M/lib/ape/lib9.a"
  7. #include <u.h> /* ick; need Rune defined below */
  8. #define MORDER 0x0003 /* mask for bits defining order of mounting */
  9. #define MREPL 0x0000 /* mount replaces object */
  10. #define MBEFORE 0x0001 /* mount goes before others in union directory */
  11. #define MAFTER 0x0002 /* mount goes after others in union directory */
  12. #define MCREATE 0x0004 /* permit creation in mounted directory */
  13. #define MRECOV 0x0008 /* perform recovery if mount channel is lost */
  14. #define MCACHE 0x0010 /* cache some data */
  15. #define MMASK 0x0007 /* all bits on */
  16. #define FORKPG 1
  17. #define FORKEG 2
  18. #define FORKFD 4
  19. #define SG_RONLY 0040 /* read only */
  20. #define SG_CEXEC 0100 /* detach on exec */
  21. enum
  22. {
  23. RFNAMEG = (1<<0),
  24. RFENVG = (1<<1),
  25. RFFDG = (1<<2),
  26. RFNOTEG = (1<<3),
  27. RFPROC = (1<<4),
  28. RFMEM = (1<<5),
  29. RFNOWAIT = (1<<6),
  30. RFCNAMEG = (1<<10),
  31. RFCENVG = (1<<11),
  32. RFCFDG = (1<<12),
  33. RFREND = (1<<13)
  34. };
  35. extern char *argv0;
  36. #define ARGBEGIN for((argv0||(argv0=*argv)),argv++,argc--;\
  37. argv[0] && argv[0][0]=='-' && argv[0][1];\
  38. argc--, argv++) {\
  39. char *_args, *_argt;\
  40. Rune _argc;\
  41. _args = &argv[0][1];\
  42. if(_args[0]=='-' && _args[1]==0){\
  43. argc--; argv++; break;\
  44. }\
  45. _argc = 0;\
  46. while(*_args && (_args += chartorune(&_argc, _args)))\
  47. switch(_argc)
  48. #define ARGEND SET(_argt);USED(_argt,_argc,_args);}USED(argv, argc);
  49. #define ARGF() (_argt=_args, _args="",\
  50. (*_argt? _argt: argv[1]? (argc--, *++argv): 0))
  51. #define EARGF(x) (_argt=_args, _args="",\
  52. (*_argt? _argt: argv[1]? (argc--, *++argv): ((x), abort(), (char*)0)))
  53. #define ARGC() _argc
  54. extern int errstr(char*, unsigned int);
  55. extern int bind(char*, char*, int);
  56. extern int mount(int, int, char*, int, char*);
  57. extern int unmount(char*, char*);
  58. extern int rfork(int);
  59. extern int segattach(int, char*, void*, unsigned long);
  60. extern int segbrk(void*, void*);
  61. extern int segdetach(void*);
  62. extern int segflush(void*, unsigned long);
  63. extern int segfree(void*, unsigned long);
  64. extern unsigned long rendezvous(unsigned long, unsigned long);
  65. extern unsigned long getfcr(void);
  66. extern unsigned long getfsr(void);
  67. extern void setfcr(unsigned long);
  68. extern void setfsr(unsigned long);
  69. #endif