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