WebGet & WebPost Utilities
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

80 líneas
1.9KB

  1. /**
  2. * @PROJECT WebGet Downloader
  3. * @COPYRIGHT See COPYING in the top level directory
  4. * @FILE webpost.c
  5. * @PURPOSE Web POST Operation Dumper
  6. * @DEVELOPERS Al Globus <globus@nas.nasa.gov>
  7. * Rafal Kupiec <belliash@asiotec.eu.org>
  8. * Jef Poskanzer <jef@mail.acme.com>
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <signal.h>
  13. #include "libweb.h"
  14. int main(int argc, char** argv) {
  15. int argn;
  16. char* referer;
  17. char* user_agent;
  18. char* auth_token;
  19. int ncookies;
  20. char* cookies[MAX_COOKIES];
  21. char* header_name;
  22. char* header_value;
  23. argv0 = argv[0];
  24. argn = 1;
  25. timeout = 60;
  26. referer = (char*) 0;
  27. user_agent = "http_post";
  28. auth_token = (char*) 0;
  29. ncookies = 0;
  30. header_name = (char*) 0;
  31. header_value = (char*) 0;
  32. verbose = 0;
  33. while(argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
  34. if(strcmp(argv[argn], "-t") == 0 && argn + 1 < argc) {
  35. ++argn;
  36. timeout = atoi(argv[argn]);
  37. } else if(strcmp(argv[argn], "-r") == 0 && argn + 1 < argc) {
  38. ++argn;
  39. referer = argv[argn];
  40. } else if(strcmp(argv[argn], "-u") == 0 && argn + 1 < argc) {
  41. ++argn;
  42. user_agent = argv[argn];
  43. } else if(strcmp(argv[argn], "-a") == 0 && argn + 1 < argc) {
  44. ++argn;
  45. auth_token = argv[argn];
  46. } else if(strcmp(argv[argn], "-c") == 0 && argn + 1 < argc) {
  47. if(ncookies >= MAX_COOKIES) {
  48. (void) fprintf(stderr, "%s: too many cookies\n", argv0);
  49. exit(1);
  50. }
  51. ++argn;
  52. cookies[ncookies++] = argv[argn];
  53. } else if(strcmp(argv[argn], "-h") == 0 && argn + 2 < argc) {
  54. ++argn;
  55. header_name = argv[argn];
  56. ++argn;
  57. header_value = argv[argn];
  58. } else if(strcmp(argv[argn], "-v") == 0) {
  59. verbose = 1;
  60. } else {
  61. usage();
  62. }
  63. ++argn;
  64. }
  65. if(argn >= argc) {
  66. usage();
  67. }
  68. url = argv[argn];
  69. ++argn;
  70. (void) signal(SIGALRM, sigcatch);
  71. postURL(url, referer, user_agent, auth_token, ncookies, cookies, header_name, header_value, &(argv[argn]), argc - argn);
  72. exit(0);
  73. }