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

Rozdiely pre dead/mail2sms/http.c medzi verziami 1.13 a 1.14

verzia 1.13, 2001/11/14 16:00:07 verzia 1.14, 2001/11/16 19:30:01
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.14  2001/11/16 19:30:01  host8
    * Patched bug in declaration/definition of global variable debug.
    *
  * Revision 1.13  2001/11/14 16:00:07  host8   * Revision 1.13  2001/11/14 16:00:07  host8
  * Changed some debug messages.   * Changed some debug messages.
  * Improvements in cookies (still not works fine).   * Improvements in cookies (still not works fine).
Riadok 15 
Riadok 18 
  * Revision 1.10  2001/10/30 18:18:12  jombik9   * Revision 1.10  2001/10/30 18:18:12  jombik9
  * Improvements.   * Improvements.
  *   *
  * Revision 1.9  2001/10/30 17:24:01  host8  
  * New implementation of http request.  
  *  
  * 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  
  * First implementation of login with password.  
  *  
  * Revision 1.6  2001/10/25 17:37:58  host8  
  * Support only some sms-gates available.  
  *  
  * Revision 1.5  2001/10/25 09:37:57  host8  
  * Added support for selection only some sms-gates.  
  */   */
   
 #include <stdio.h>  #include <stdio.h>
Riadok 163  static COOKIE **add_to_cookies(COOKIE **
Riadok 151  static COOKIE **add_to_cookies(COOKIE **
 // static COOKIE *parse_cookie(char *str) {{{  // static COOKIE *parse_cookie(char *str) {{{
 static COOKIE *parse_cookie(char *str)  static COOKIE *parse_cookie(char *str)
 {  {
         COOKIE *c;          COOKIE *c = NULL;
         char **array;          char **array;
         int i;          int i, j;
           char *tmp;
         /* Cookies {{{          /* Cookies {{{
            read(4, "HTTP/1.1 302 Object moved\r\n             read(4, "HTTP/1.1 302 Object moved\r\n
 Server: Microsoft-IIS/5.0\r\n  Server: Microsoft-IIS/5.0\r\n
Riadok 185  Cookie2: $Version=\"1\"\r\n
Riadok 174  Cookie2: $Version=\"1\"\r\n
 Cookie: mtnsms%2Ep%2E2=color=0&cn=rajo%40host%2Esk&akey=; mtnsms%2Et%2E2=skey=178A2593%2D5FA7%2D406B%2D8DE9%2D5EA0B8A4BB15\r\n\r\n", 747) = 747  Cookie: mtnsms%2Ep%2E2=color=0&cn=rajo%40host%2Esk&akey=; mtnsms%2Et%2E2=skey=178A2593%2D5FA7%2D406B%2D8DE9%2D5EA0B8A4BB15\r\n\r\n", 747) = 747
          *  }}} Cookies */           *  }}} Cookies */
   
         c = new_cookie();  
         array = strdyn_explode_chr(str, ';');          array = strdyn_explode_chr(str, ';');
   
           /* search for cookies with same domain,
            * if found, not alloc new cookie.
            */
         for (i=0; array[i] != NULL; i++) {          for (i=0; array[i] != NULL; i++) {
                 char *tmp;                  tmp = array[i];
                   if (tmp == strstr(tmp, " domain=")) {
                           int count;
   
                           count = get_size_cookies(cookies);
                           for (j=(count-1); j >= 0; j--) {
                                   if (cookies[j] != NULL &&
                                                                                   cookies[j]->domain != NULL &&
                                                                                   strstr(tmp, cookies[j]->domain)
                                                                                   != NULL) {
                                           /* same domain found, set c to these */
                                           c = cookies[j];
                                           break;
                                   }
                           }
                   }
           }
           if (c == NULL) { // domain not found
                   c = new_cookie();
           }
   
           for (i=0; array[i] != NULL; i++) {
 #ifdef DEBUG  #ifdef DEBUG
                 if (debug > 4)                  if (debug > 4)
                         fprintf(stderr, "COOKIES: parsed_cookie[%d] = '%s'\n", i,                          fprintf(stderr, "COOKIES: parsed_cookie[%d] = '%s'\n", i,
Riadok 210  Cookie: mtnsms%2Ep%2E2=color=0&cn=rajo%4
Riadok 221  Cookie: mtnsms%2Ep%2E2=color=0&cn=rajo%4
                 else {                  else {
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug > 4)                          if (debug > 4)
                                 fprintf(stderr, "COOKIES: cookies->text-old = '%s'",                                  fprintf(stderr, "COOKIES: cookies->text-old = '%s'\n",
                                                                                 c->text);                                                                                  c->text);
 #endif  #endif
                         if (c->text == NULL)                          if (c->text == NULL)
                                 c->text = strdup(tmp);                                  c->text = strdup(tmp);
                         else {                          else {
                                 char *ar[2];                                  char *ar[3];
   
                                 ar[0] = c->text, ar[1] = tmp;                                  ar[0] = c->text, ar[1] = tmp, ar[2] = NULL;
                                 c->text = strdyn_implode_str(ar, "");                                  c->text = strdyn_implode2_str(ar, "; ");
                         }                          }
 #ifdef DEBUG  #ifdef DEBUG
                         if (debug > 4)                          if (debug > 4)
                                 fprintf(stderr, "COOKIES: new = '%s'\n", c->text);                                  fprintf(stderr, "COOKIES: cookies->text-new = '%s'\n",
                                                                                   c->text);
 #endif  #endif
                 }                  }
         }          }
Riadok 247  static char *get_cookie(HTTP_REQUEST *r)
Riadok 259  static char *get_cookie(HTTP_REQUEST *r)
                 return (NULL);                  return (NULL);
   
         count = get_size_cookies(cookies);          count = get_size_cookies(cookies);
 #ifdef DEBUG  
         fprintf(stderr, "COOKIES: count = %d in get_cookie()\n", count);  
         if (debug > 4)  
                 fprintf(stderr, "COOKIES: Comparing '%s' with: \n", r->host);  
 #endif  
         for (i=(count-1); i >= 0; i--) {          for (i=(count-1); i >= 0; i--) {
 #ifdef DEBUG  
                 if (debug > 4)  
                         fprintf(stderr, "COOKIES: %02d '%s'\n", i, cookies[i]->domain);  
 #endif  
                 if (cookies[i] != NULL &&                  if (cookies[i] != NULL &&
                                                                 cookies[i]->domain != NULL &&                                                                  cookies[i]->domain != NULL &&
                                                                 strstr(r->host, cookies[i]->domain)                                                                  strstr(r->host, cookies[i]->domain)
Riadok 267  static char *get_cookie(HTTP_REQUEST *r)
Riadok 270  static char *get_cookie(HTTP_REQUEST *r)
         }          }
 #ifdef DEBUG  #ifdef DEBUG
         if (debug > 4)          if (debug > 4)
                 fprintf(stderr, "COOKIES: END of comparising, returning '%s'\n", str);                  fprintf(stderr, "COOKIES: get_cookie() = '%s'\n", str);
 #endif  #endif
   
         return (str);          return (str);
Riadok 698  static void http_read_source(HTTP_REQUES
Riadok 701  static void http_read_source(HTTP_REQUES
                         }                          }
                 } /* }}} End of Handling '302 Object Moved' */                  } /* }}} End of Handling '302 Object Moved' */
                 if (info) {                  if (info) {
                         fprintf(stderr, "\t%.*s\n", (int)(strlen(buf)-2), buf);                          fprintf(stderr, "\t%.*s\n", (int)(strlen(buf)-1), buf);
                         info=0;                          info=0;
                         if (strstr(buf, "HTTP/1.") != NULL) {                          if (strstr(buf, "HTTP/1.") != NULL) {
                                 if ((buf+8) == strstr(buf, " 200 OK")) {                                  if ((buf+8) == strstr(buf, " 200 OK")) {
Riadok 716  static void http_read_source(HTTP_REQUES
Riadok 719  static void http_read_source(HTTP_REQUES
                                 if ((buf+8) == strstr(buf, " 404 Object Not Found")) {                                  if ((buf+8) == strstr(buf, " 404 Object Not Found")) {
                                         bad_request = 1;                                          bad_request = 1;
                                 }                                  }
                                   if ((buf+8) == strstr(buf, " 500 Server Error")) {
                                           bad_request = 1;
                                   }
                         }                          }
                 }                  }
 #ifdef DEBUG  #ifdef DEBUG
Riadok 808  int http_request(int method, char *file,
Riadok 814  int http_request(int method, char *file,
                 if (debug > 4)                  if (debug > 4)
                         fprintf(stderr, "HTTP: sending cookies:\r\n"                          fprintf(stderr, "HTTP: sending cookies:\r\n"
                                                                         "Cookie2: $Version=\"1\"\r\n"                                                                          "Cookie2: $Version=\"1\"\r\n"
                                                                         "Cookie: %s;\r\n",                                                                          "Cookie: %s\r\n",
                                                                         get_cookie(r));                                                                          get_cookie(r));
 #endif  #endif
                 fprintf(r->frw, "Cookie2: $Version=\"1\"\r\nCookie: %s;\r\n",                  fprintf(r->frw, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n",
                                                                 get_cookie(r));                                                                  get_cookie(r));
         }          }
         if (fmt != NULL) {          if (fmt != NULL) {

Legend:
Odstranené z verzie1.13  
zmenené riadky
  Pridané vo verzii1.14

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