dat.h 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. /*
  2. * This file is part of the UCB release of Plan 9. It is subject to the license
  3. * terms in the LICENSE file found in the top-level directory of this
  4. * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
  5. * part of the UCB release of Plan 9, including this file, may be copied,
  6. * modified, propagated, or distributed except according to the terms contained
  7. * in the LICENSE file.
  8. */
  9. typedef struct Client Client;
  10. typedef struct Ctl Ctl;
  11. typedef struct Ibuf Ibuf;
  12. typedef struct Url Url;
  13. /* simple buffered i/o for network connections; shared by http, ftp */
  14. struct Ibuf
  15. {
  16. int fd;
  17. Ioproc *io;
  18. char buf[4096];
  19. char *rp, *wp;
  20. };
  21. struct Ctl
  22. {
  23. int acceptcookies;
  24. int sendcookies;
  25. int redirectlimit;
  26. char *useragent;
  27. };
  28. struct Client
  29. {
  30. Url *url;
  31. Url *baseurl;
  32. Ctl ctl;
  33. Channel *creq; /* chan(Req*) */
  34. int num;
  35. int plumbed;
  36. char *contenttype;
  37. char *postbody;
  38. char *redirect;
  39. char *authenticate;
  40. char *ext;
  41. int npostbody;
  42. int havepostbody;
  43. int iobusy;
  44. int bodyopened;
  45. Ioproc *io;
  46. int ref;
  47. void *aux;
  48. };
  49. /*
  50. * If ischeme is USunknown, then the given URL is a relative
  51. * URL which references the "current document" in the context of the base.
  52. * If this is the case, only the "fragment" and "url" members will have
  53. * meaning, and the given URL structure may not be used as a base URL itself.
  54. */
  55. enum
  56. {
  57. USunknown,
  58. UShttp,
  59. UShttps,
  60. USftp,
  61. USfile,
  62. UScurrent,
  63. };
  64. struct Url
  65. {
  66. int ischeme;
  67. char* url;
  68. char* scheme;
  69. int (*open)(Client*, Url*);
  70. int (*read)(Client*, Req*);
  71. void (*close)(Client*);
  72. char* schemedata;
  73. char* authority;
  74. char* user;
  75. char* passwd;
  76. char* host;
  77. char* port;
  78. char* path;
  79. char* query;
  80. char* fragment;
  81. union {
  82. struct {
  83. char *page_spec;
  84. } http;
  85. struct {
  86. char *path_spec;
  87. char *type;
  88. } ftp;
  89. };
  90. };
  91. enum
  92. {
  93. STACK = 32*1024, /* was 16*1024; there are big arrays on the stack */
  94. };
  95. extern Client** client;
  96. extern int cookiedebug;
  97. extern Srv fs;
  98. extern int fsdebug;
  99. extern Ctl globalctl;
  100. extern int nclient;
  101. extern int urldebug;
  102. extern int httpdebug;
  103. extern char* status[];