WebGet & WebPost Utilities
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

libweb.h 3.2KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /**
  2. * @PROJECT WebGet Downloader
  3. * @COPYRIGHT See COPYING in the top level directory
  4. * @FILE libweb.h
  5. * @PURPOSE Common Web Library
  6. * @DEVELOPERS Al Globus <globus@nas.nasa.gov>
  7. * Rafal Kupiec <belliash@asiotec.eu.org>
  8. * Jef Poskanzer <jef@mail.acme.com>
  9. */
  10. #ifndef __LIBWEB_H
  11. #define __LIBWEB_H
  12. #define HDST_LINE1_PROTOCOL 0
  13. #define HDST_LINE1_WHITESPACE 1
  14. #define HDST_LINE1_STATUS 2
  15. #define HDST_BOL 10
  16. #define HDST_TEXT 11
  17. #define HDST_LF 12
  18. #define HDST_CR 13
  19. #define HDST_CRLF 14
  20. #define HDST_CRLFCR 15
  21. #define PROTO_HTTP 0
  22. #define PROTO_HTTPS 1
  23. #define MAX_COOKIES 20
  24. char* argv0;
  25. int timeout;
  26. char* url;
  27. int verbose;
  28. static int b64_decode_table[256] = {
  29. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 00-0F */
  30. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 10-1F */
  31. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,62,-1,-1,-1,63, /* 20-2F */
  32. 52,53,54,55,56,57,58,59,60,61,-1,-1,-1,-1,-1,-1, /* 30-3F */
  33. -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, /* 40-4F */
  34. 15,16,17,18,19,20,21,22,23,24,25,-1,-1,-1,-1,-1, /* 50-5F */
  35. -1,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, /* 60-6F */
  36. 41,42,43,44,45,46,47,48,49,50,51,-1,-1,-1,-1,-1, /* 70-7F */
  37. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 80-8F */
  38. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* 90-9F */
  39. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* A0-AF */
  40. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* B0-BF */
  41. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* C0-CF */
  42. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* D0-DF */
  43. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1, /* E0-EF */
  44. -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1 /* F0-FF */
  45. };
  46. static char b64_encode_table[64] = {
  47. 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', /* 0-7 */
  48. 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', /* 8-15 */
  49. 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', /* 16-23 */
  50. 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', /* 24-31 */
  51. 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', /* 32-39 */
  52. 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', /* 40-47 */
  53. 'w', 'x', 'y', 'z', '0', '1', '2', '3', /* 48-55 */
  54. '4', '5', '6', '7', '8', '9', '+', '/' /* 56-63 */
  55. };
  56. int b64_encode(unsigned char* ptr, int len, char* space, int size);
  57. void check(void* ptr);
  58. off_t file_bytes(const char* filename);
  59. int file_copy(const char* filename, char* buf);
  60. int getURL(char* url, char* referer, char* user_agent, char* auth_token, int ncookies, char** cookies, char* header_name, char* header_value);
  61. int getURLbyParts(int protocol, char* host, unsigned short port, char* file, char* referer, char* user_agent, char* auth_token, int ncookies, char** cookies, char* header_name, char* header_value);
  62. void* malloc_check(size_t size);
  63. int open_client_socket(char* hostname, unsigned short port);
  64. void postURL(char* url, char* referer, char* user_agent, char* auth_token, int ncookies, char** cookies, char* header_name, char* header_value, char** args, int argc);
  65. void postURLbyParts(int protocol, char* host, unsigned short port, char* file, char* referer, char* user_agent, char* auth_token, int ncookies, char** cookies, char* header_name, char* header_value, char** args, int argc);
  66. void show_error(char* cause);
  67. void sigcatch(int sig);
  68. void strencode(char* to, char* from);
  69. void usage();
  70. #endif