Platon Technologies
neprihlásený Prihlásiť Registrácia
SlovakEnglish
open source software development oslavujeme 10 rokov vývoja otvoreného softvéru! Nedeľa, 25. október 2026

Rozdiely pre dead/mail2sms/http.c medzi verziami 1.11 a 1.12

verzia 1.11, 2001/11/12 16:08:00 verzia 1.12, 2001/11/12 20:19:10
Riadok 1 
Riadok 1 
 /*  /*
  * Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk>   * Author: Lubomir Host 'rajo' <host8@kepler.fmph.uniba.sk>
  * $Log$   * $Log$
    * Revision 1.12  2001/11/12 20:19:10  host8
    * http_connect() probably works fine.
    * Some problems with http_requests for www.mtnsms.com.
    *
  * Revision 1.11  2001/11/12 16:08:00  host8   * Revision 1.11  2001/11/12 16:08:00  host8
  * Big improvements in http. connect() doesn't work correctly yet.   * Big improvements in http. connect() doesn't work correctly yet.
  *   *
Riadok 401  static FILE *http_connect(HTTP_REQUEST *
Riadok 405  static FILE *http_connect(HTTP_REQUEST *
                         serv_addr.sin_addr.s_addr = *((u_long *) (pent->h_addr));                          serv_addr.sin_addr.s_addr = *((u_long *) (pent->h_addr));
         }          }
         if (serv_addr.sin_addr.s_addr == INADDR_NONE) {          if (serv_addr.sin_addr.s_addr == INADDR_NONE) {
                 fprintf(stderr, "Can't connect to %s[%s] - %s\n", servers[idx].desc,  #ifdef DEBUG
                                                                 servers[idx].ip, strerror(errno));                  if (debug > 8) {
                           fprintf(stderr, "%s: %d - catched error\n",
                                                                           __FILE__, __LINE__);
                   }
   #endif
                   fprintf(stderr, "Can't connect to %s[%s:%hd] - %s\n",
                                                                   servers[idx].desc,
                                                                   servers[idx].ip,
                                                                   r->port, strerror(errno));
                 return (NULL);                  return (NULL);
         }          }
   
Riadok 412  static FILE *http_connect(HTTP_REQUEST *
Riadok 424  static FILE *http_connect(HTTP_REQUEST *
                         struct servent *pent;                          struct servent *pent;
                         char str_port[10];                          char str_port[10];
   
                         if (snprintf(str_port, 9, "%d", r->port) == -1) {  #ifdef DEBUG
                                 fprintf(stderr, "Can't connect to %s[%s] - %s\n",                          if (debug > 6) {
                                   fprintf(stderr, "(u_short) r->port = %hd\n", r->port);
                           }
   #endif
                           if (snprintf(str_port, 9, "%hd", r->port) == -1) {
                                   fprintf(stderr, "Can't connect to %s[%s:%s] - %s\n",
                                                                                 servers[idx].desc,                                                                                  servers[idx].desc,
                                                                                 servers[idx].ip, strerror(errno));                                                                                  servers[idx].ip,
                                                                                   str_port, strerror(errno));
                                 return (NULL);                                  return (NULL);
                         }                          }
                         pent = getservbyname(str_port, "tcp");                          pent = getservbyname(str_port, "tcp");
Riadok 423  static FILE *http_connect(HTTP_REQUEST *
Riadok 441  static FILE *http_connect(HTTP_REQUEST *
                                 serv_addr.sin_port = pent->s_port;                                  serv_addr.sin_port = pent->s_port;
                 }                  }
                 if (serv_addr.sin_port == 0) {                  if (serv_addr.sin_port == 0) {
                         fprintf(stderr, "Can't connect to %s[%s] - %s\n", servers[idx].desc,  #ifdef DEBUG
                                                                         servers[idx].ip, strerror(errno));                          if (debug > 8) {
                                   fprintf(stderr, "%s: %d - catched error\n",
                                                                                   __FILE__, __LINE__);
                           }
   #endif
                           fprintf(stderr, "Can't connect to %s[%s:%hd] - %s\n",
                                                                           servers[idx].desc,
                                                                           servers[idx].ip,
                                                                           r->port, strerror(errno));
                         return (NULL);                          return (NULL);
                 }                  }
         }          }
         else {          else {
                 // No port specified ... use telnet port. //                  // No port specified ... use telnet port. //
                 struct servent *pent = getservbyname ("www", "tcp");                  struct servent *pent;
   
                   pent = getservbyname ("www", "tcp");
                 if (pent == NULL)                  if (pent == NULL)
                         serv_addr.sin_port = htons(23);                          serv_addr.sin_port = htons(80);
                 else                  else
                         serv_addr.sin_port = pent->s_port;                          serv_addr.sin_port = pent->s_port;
         }          }
Riadok 449  static FILE *http_connect(HTTP_REQUEST *
Riadok 477  static FILE *http_connect(HTTP_REQUEST *
                 }                  }
         }          }
         else {          else {
                 fprintf(stderr, "Can't connect to %s[%s] - %s\n", servers[idx].desc,  #ifdef DEBUG
                                                                 servers[idx].ip, strerror(errno));                  if (debug > 8) {
                           fprintf(stderr, "%s: %d - catched error\n",
                                                                           __FILE__, __LINE__);
                   }
   #endif
                   fprintf(stderr, "Can't connect to %s[%s:%hd] - %s\n",
                                                                   servers[idx].desc,
                                                                   servers[idx].ip,
                                                                   r->port, strerror(errno));
                 return (NULL);                  return (NULL);
         }          }
   
         fprintf(stderr, "Can't connect to %s[%s] - %s\n", servers[idx].desc,  #ifdef DEBUG
                                                         servers[idx].ip, strerror(errno));          if (debug > 8) {
                   fprintf(stderr, "%s: %d - catched error\n",
                                                                   __FILE__, __LINE__);
           }
   #endif
           fprintf(stderr, "Can't connect to %s[%s:%hd] - %s\n",
                                                           servers[idx].desc,
                                                           servers[idx].ip,
                                                           r->port, strerror(errno));
         return (NULL);          return (NULL);
   
   
Riadok 632  static void http_read_source(HTTP_REQUES
Riadok 676  static void http_read_source(HTTP_REQUES
 #endif  #endif
                                         search_for_link = 1 ;                                          search_for_link = 1 ;
                                 }                                  }
                                   if ((buf+8) == strstr(buf, " 400 Bad Request")) {
                                           exit(1);
                                   }
                                 if ((buf+8) == strstr(buf, " 404 Object Not Found")) {                                  if ((buf+8) == strstr(buf, " 404 Object Not Found")) {
                                         exit(1);                                          exit(1);
                                 }                                  }
Riadok 666  int http_request(int method, char *file,
Riadok 713  int http_request(int method, char *file,
         va_list ap;          va_list ap;
         HTTP_REQUEST *r;          HTTP_REQUEST *r;
   
         r = new_request();  
   
         r->method = method;  
         r->host = strdup(host);  
         r->file = strdup(file);  
         requests = add_to_requests(requests, r);  
   
         if ((r->frw = http_connect(r)) == NULL) {  
                 exit(errno);  
         }  
 #ifdef DEBUG  #ifdef DEBUG
         if (debug) { // Debug code STAHUJEM/POSIELAM {{{          if (debug) { // Debug code STAHUJEM/POSIELAM {{{
                 if (method == HTTP_GET) {                  if (method == HTTP_GET) {
Riadok 686  int http_request(int method, char *file,
Riadok 723  int http_request(int method, char *file,
                 }                  }
         } // }}}          } // }}}
 #endif  #endif
   
           r = new_request();
   
           r->port = (u_short) 80;
           r->method = method;
           r->host = strdup(host);
           r->file = strdup(file);
           requests = add_to_requests(requests, r);
   
           if ((r->frw = http_connect(r)) == NULL) {
                   exit(errno);
           }
         switch (r->method) {          switch (r->method) {
                 case HTTP_GET:                  case HTTP_GET:
                         fprintf(r->frw, "GET %s HTTP/1.0\r\n", file);                          fprintf(r->frw, "GET %s HTTP/1.0\r\n", file);
Riadok 740  int http_request(int method, char *file,
Riadok 789  int http_request(int method, char *file,
 #endif  #endif
         return 0;          return 0;
 } // }}}  } // }}}
   // char *get_last_hostname(void) {{{
   char *get_last_hostname(void)
   {
           int count;
   
           count = get_size_requests(requests);
   #ifdef DEBUG
           if (debug > 6) {
                   fprintf(stderr, "get_last_hostname() = '%s'\n",
                                                                   requests[count-1]->host);
           }
   #endif
   
           return (requests[count-1]->host);
   }
   // }}}
 // void http_init(void) {{{  // void http_init(void) {{{
 void http_init(void)  void http_init(void)
 {  {

Legend:
Odstranené z verzie1.11  
zmenené riadky
  Pridané vo verzii1.12

Platon Group <platon@platon.sk> http://platon.sk/
Copyright © 2002-2006 Platon Group
Stránka používa redakčný systém Metafox
Na začiatok