web.h 705 B

123456789101112131415161718192021222324252627
  1. #include "unp.h"
  2. #define MAXFILES 20
  3. #define SERV "80" /* port number or service name */
  4. struct file {
  5. char *f_name; /* filename */
  6. char *f_host; /* hostname or IPv4/IPv6 address */
  7. int f_fd; /* descriptor */
  8. int f_flags; /* F_xxx below */
  9. } file[MAXFILES];
  10. #define F_CONNECTING 1 /* connect() in progress */
  11. #define F_READING 2 /* connect() complete; now reading */
  12. #define F_DONE 4 /* all done */
  13. #define GET_CMD "GET %s HTTP/1.0\r\n\r\n"
  14. /* globals */
  15. int nconn, nfiles, nlefttoconn, nlefttoread, maxfd;
  16. fd_set rset, wset;
  17. /* function prototypes */
  18. void home_page(const char *, const char *);
  19. void start_connect(struct file *);
  20. void write_get_cmd(struct file *);