dat.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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 *ext;
  32. int npostbody;
  33. int havepostbody;
  34. int iobusy;
  35. int bodyopened;
  36. Ioproc *io;
  37. int ref;
  38. void *aux;
  39. };
  40. /*
  41. * If ischeme is USunknown, then the given URL is a relative
  42. * URL which references the "current document" in the context of the base.
  43. * If this is the case, only the "fragment" and "url" members will have
  44. * meaning, and the given URL structure may not be used as a base URL itself.
  45. */
  46. enum
  47. {
  48. USunknown,
  49. UShttp,
  50. UShttps,
  51. USftp,
  52. USfile,
  53. UScurrent,
  54. };
  55. struct Url
  56. {
  57. int ischeme;
  58. char* url;
  59. char* scheme;
  60. int (*open)(Client*, Url*);
  61. int (*read)(Client*, Req*);
  62. void (*close)(Client*);
  63. char* schemedata;
  64. char* authority;
  65. char* user;
  66. char* passwd;
  67. char* host;
  68. char* port;
  69. char* path;
  70. char* query;
  71. char* fragment;
  72. union {
  73. struct {
  74. char *page_spec;
  75. } http;
  76. struct {
  77. char *path_spec;
  78. char *type;
  79. } ftp;
  80. };
  81. };
  82. enum
  83. {
  84. STACK = 16384,
  85. };
  86. extern Client** client;
  87. extern int cookiedebug;
  88. extern Srv fs;
  89. extern int fsdebug;
  90. extern Ctl globalctl;
  91. extern int nclient;
  92. extern int urldebug;
  93. extern int httpdebug;
  94. extern char* status[];