dat.h 1.6 KB

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