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.7 a 1.8

verzia 1.7, 2001/10/25 20:05:28 verzia 1.8, 2001/10/27 20:32:43
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.8  2001/10/27 20:32:43  host8
    * mail2sms.c splited to multiple files.
    * Little improvements in Makefile.in.
    *
  * Revision 1.7  2001/10/25 20:05:28  host8   * Revision 1.7  2001/10/25 20:05:28  host8
  * First implementation of login with password.   * First implementation of login with password.
  *   *
Riadok 35 
Riadok 39 
 #endif  #endif
 #include "mail2sms.h"  #include "mail2sms.h"
 #include "strings.h"  #include "strings.h"
   #include "http.h"
   
 // Function http_set_cookie() {{{  // Function http_set_cookie() {{{
 void http_set_cookie(char *str)  void http_set_cookie(char *str)
Riadok 100  FILE *http_connect(void)
Riadok 105  FILE *http_connect(void)
 // Function http_read_source() {{{  // Function http_read_source() {{{
 void http_read_source(FILE *f, char *host, char *file)  void http_read_source(FILE *f, char *host, char *file)
 {  {
           int search_for_link = 0;
 #ifdef DEBUG  #ifdef DEBUG
         int info = g.debug;          int info = g.debug;
 #else  #else
Riadok 108  void http_read_source(FILE *f, char *hos
Riadok 114  void http_read_source(FILE *f, char *hos
   
         while (1) {          while (1) {
                 char bla[1024];                  char bla[1024];
                 //char *found;                  int i;
   
                 if (fgets(bla, sizeof(bla), f) == NULL)                  if (fgets(bla, sizeof(bla), f) == NULL)
                         break;                          break;
                   if (search_for_link == 1) {  /* Handling " 302 Object Moved" */
                           if (bla == strstr(bla, "Location: ")) {
                                   if ((g.goto_object_moved = strdup(bla)) == NULL) {
                                           fprintf(stderr, "strdup(%s) failed!\n", bla);
                                           exit(1);
                                   }
                                   while (strlen(g.goto_object_moved) > 0 &&
                                                                                   isspace(g.goto_object_moved[
                                                                                           strlen(g.goto_object_moved)
                                                                                           - 1]))
                                           g.goto_object_moved[
                                                   strlen(g.goto_object_moved) - 1] = '\0';
   #ifdef DEBUG
                                   fprintf(stderr, "g.goto_object_moved = '%s'\n",
                                                                                   g.goto_object_moved);
   #endif
   
                                   search_for_link = 0;
                           }
                   }
                 if (info) {                  if (info) {
                         fprintf(stderr, "\t%.*s\n", (int)(strlen(bla)-2), bla);                          fprintf(stderr, "\t%.*s\n", (int)(strlen(bla)-2), bla);
                         info=0;                          info=0;
Riadok 119  void http_read_source(FILE *f, char *hos
Riadok 145  void http_read_source(FILE *f, char *hos
                                 if ((bla+8) == strstr(bla, " 200 OK")) {                                  if ((bla+8) == strstr(bla, " 200 OK")) {
                                         http_set_referer(host, file);                                          http_set_referer(host, file);
                                 }                                  }
                                 else if ((bla+8) == strstr(bla, " 302 Object Moved")) {                                  if ((bla+8) == strstr(bla, " 302 Object moved")) {
                                         /* TODO: implement this error-handling  #ifdef DEBUG
                                         */                                          fprintf(stderr, "Searching for 'Location: '...\n");
   #endif
                                           search_for_link = 1 ;
                                   }
                                   if ((bla+8) == strstr(bla, " 404 Object Not Found")) {
                                           exit(1);
                                 }                                  }
                         }                          }
                 }                  }
Riadok 133  void http_read_source(FILE *f, char *hos
Riadok 164  void http_read_source(FILE *f, char *hos
                 if (bla == strstr(bla, "Set-Cookie: "))                  if (bla == strstr(bla, "Set-Cookie: "))
                         http_set_cookie(bla);                          http_set_cookie(bla);
         }          }
   #ifdef DEBUG
           if (search_for_link == 1) {
                   fprintf(stderr, "Link NOT FOUND!\n");
           }
   #endif
         fclose (f);          fclose (f);
   
         /*  
            if (strstr(bla, "Kvôli neznámej chybe sa nepodarilo odosla SMS"  
            " správu. Odošlite ju ešte raz.")  
            != NULL) {  
            fprintf(stderr, "\t%.70s", bla+23);  
            return(1);  
            }  
            found = strstr(bla, "Na toto \350\355slo m\364\236te "  
            "dnes posla\235 e\232te");  
            if (found != NULL) {  
            fprintf(stderr, "\tMozno poslat este %.5s sprav.\n", found + 37);  
            }  
            if (info) {  
            fprintf(stderr, "\t%.*s\n", (int)(strlen(bla)-2), bla);  
            info=0;  
            }  
            */  
 } // }}}  } // }}}
 // Function http_request() {{{  // Function http_request() {{{
 int http_request(int method, char *file, char *host, char *fmt, ...)  int http_request(int method, char *file, char *host, char *fmt, ...)
Riadok 166  int http_request(int method, char *file,
Riadok 185  int http_request(int method, char *file,
                 if (method == HTTP_GET) {                  if (method == HTTP_GET) {
                         fprintf(stderr, "STAHUJEM: %s%s\n", host, file);                          fprintf(stderr, "STAHUJEM: %s%s\n", host, file);
                 }                  }
                 else {                  else if (method == HTTP_POST) {
                         fprintf(stderr, "POSIELAM: %s%s\n", host, file);                          fprintf(stderr, "POSIELAM: %s%s\n", host, file);
                 }                  }
         } // }}}          } // }}}
Riadok 194  int http_request(int method, char *file,
Riadok 213  int http_request(int method, char *file,
         fprintf(f, "Accept-Encoding: gzip, compress\r\n");          fprintf(f, "Accept-Encoding: gzip, compress\r\n");
         fprintf(f, "Accept-Language: en\r\n");          fprintf(f, "Accept-Language: en\r\n");
   
         /* unused {{{ */  
         //fprintf(f, "Accept: text/html, text/plain, audio/mod, image/*, video/*, video/mpeg, application/pgp, application/pgp, application/pdf, message/partial, message/external-body, application/postscript, x-be2, application/andrew-inset, text/richtext, text/enriched\r\nAccept: x-sun-attachment, audio-file, postscript-file, default, mail-file, sun-deskset-message, application/x-metamail-patch, text/sgml, video/mpeg, image/jpeg, image/tiff, image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif\r\nAccept: application/postscript, */*;q=0.01\r\nAccept-Encoding: gzip, compress\r\nAccept-Language: en\r\n");  
         //fprintf(f, "Negotiate: trans\r\n");  
         /* }}} unused */  
         if (method == HTTP_POST) {          if (method == HTTP_POST) {
                 fprintf(f, "Pragma: no-cache\r\n");                  fprintf(f, "Pragma: no-cache\r\n");
                 fprintf(f, "Cache-Control: no-cache\r\n");                  fprintf(f, "Cache-Control: no-cache\r\n");
Riadok 220  int http_request(int method, char *file,
Riadok 235  int http_request(int method, char *file,
         }          }
         fprintf(f, "\r\n");          fprintf(f, "\r\n");
         http_read_source(f, host, file);          http_read_source(f, host, file);
           if (g.goto_object_moved != NULL) {
                   char *tmp_host;
                   char *tmp_file;
   
                   if ((tmp_file = strstr((g.goto_object_moved+17), "/")) != NULL) {
                           tmp_host = (char *)
                                   malloc ((tmp_file-g.goto_object_moved-16)*sizeof(char));
                           strncpy(tmp_host, (g.goto_object_moved+17),
                                                                           (tmp_file-g.goto_object_moved-17));
                   if (g.goto_object_moved != NULL)
                           free(g.goto_object_moved);
                           http_request(HTTP_GET, tmp_file, tmp_host, NULL);
                           free(tmp_host);
                   } else {
   #ifdef DEBUG
                           fprintf(stderr, "Invalid link '%s'!\n", g.goto_object_moved);
   #endif
                   }
                   if (g.goto_object_moved != NULL)
                           free(g.goto_object_moved);
           }
 #ifdef DEBUG  #ifdef DEBUG
         if (g.debug) {          if (g.debug) {
                 fprintf(stderr, "HTTP request sent, reply OK...\n");                  fprintf(stderr, "HTTP request sent, reply OK...\n");

Legend:
Odstranené z verzie1.7  
zmenené riadky
  Pridané vo verzii1.8

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