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.8 a 1.9

verzia 1.8, 2001/10/27 20:32:43 verzia 1.9, 2001/10/30 17:24: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.9  2001/10/30 17:24:01  host8
    * New implementation of http request.
    *
  * Revision 1.8  2001/10/27 20:32:43  host8   * Revision 1.8  2001/10/27 20:32:43  host8
  * mail2sms.c splited to multiple files.   * mail2sms.c splited to multiple files.
  * Little improvements in Makefile.in.   * Little improvements in Makefile.in.
Riadok 13 
Riadok 16 
  *   *
  * Revision 1.5  2001/10/25 09:37:57  host8   * Revision 1.5  2001/10/25 09:37:57  host8
  * Added support for selection only some sms-gates.   * Added support for selection only some sms-gates.
  *  
  * Revision 1.4  2001/10/24 19:24:49  host8  
  * Added parameter -p (look for password).  
  *  
  * Revision 1.3  2001/09/28 16:57:04  host8  
  * Source code formated better  
  *  
  * Revision 1.2  2001/09/28 15:39:21  host8  
  * Added keyword substitution  
  *  
  */   */
   
 #include <stdio.h>  #include <stdio.h>
 #include <stdlib.h>  #include <stdlib.h>
 #include <stdarg.h>  #include <stdarg.h>
 #include <string.h>  #include <string.h>
   #include <ctype.h>
 #include <sys/socket.h>  #include <sys/socket.h>
 #include <sys/types.h>  #include <sys/types.h>
 #include <netinet/in.h>  #include <netinet/in.h>
 #include <arpa/inet.h>  #include <arpa/inet.h>
   #include <netdb.h>
   
 #ifdef HAVE_CONFIG_H  #ifdef HAVE_CONFIG_H
 #  include "config.h"  #  include "config.h"
Riadok 41 
Riadok 36 
 #include "strings.h"  #include "strings.h"
 #include "http.h"  #include "http.h"
   
 // Function http_set_cookie() {{{  static void http_set_cookie(HTTP_REQUEST *r, char *str);
 void http_set_cookie(char *str)  static void free_request(HTTP_REQUEST *r);
   static void free_requests(HTTP_REQUEST **req);
   static int get_size_requests(HTTP_REQUEST **req);
   static HTTP_REQUEST **create_requests(void);
   static HTTP_REQUEST *new_request(void);
   static HTTP_REQUEST *duplicate_request(HTTP_REQUEST *r);
   static HTTP_REQUEST **add_to_requests(HTTP_REQUEST **req, const HTTP_REQUEST *r);
   static char *get_http_referer(HTTP_REQUEST **req);
   static char *get_cookie(HTTP_REQUEST *r);
   
   HTTP_REQUEST **requests;
   
   // GetAddrInfo(const char *str, int port) {{{
   static struct addrinfo *GetAddrInfo(const char *host, int port)
 {  {
         if (str != NULL) {          struct addrinfo hints, *res;
                 if (str == strstr("Set-Cookie: ", str)) {          int error;
                         www.cookies = strdup(str + 13);  
                 }          memset(&hints, 0, sizeof(hints));
           hints.ai_family = PF_UNSPEC;
           hints.ai_socktype = SOCK_STREAM;
           error = getaddrinfo(host, "80", &hints, &res);
           if (error || !res) {
                   fprintf(stderr, "GetAddrInfo: getaddrinfo(%s, %d): %s\n", host, port,
                                                                   strerror(error));
                   res = NULL;
         }          }
   
           return res;
 } // }}}  } // }}}
 // Function http_set_referer() {{{  // http_set_cookie(HTTP_REQUEST *r, char *str) {{{
 void http_set_referer(char *host, char *file)  static void http_set_cookie(HTTP_REQUEST *r, char *str)
 {  {
         if (host != NULL && file != NULL) {          /* Cookies {{{
 #ifdef DEBUG             read(4, "HTTP/1.1 302 Object moved\r\nServer: Microsoft-IIS/5.0\r\nDate: Mon, 22 Oct 2001 16:43:36 GMT\r\nLocation: http://www4.mtnsms.com/members/contacts/contacts.asp\r\nConnection: Keep-Alive\r\nContent-Length: 173\r\nContent-Type: text/html\r\nExpires: Mon, 22 Oct 2001 16:43:36 GMT\r\nSet-Cookie: mtnsms%2Ep%2E2=color=0&cn=rajo%40host%2Esk&akey=; expires=Sat, 22-Oct-2011 16:43:36 GMT; domain=.mtnsms.com; path=/\r\nSet-Cookie: mtnsms%2Et%2E2=skey=178A2593%2D5FA7%2D406B%2D8DE9%2D5EA0B8A4BB15; domain=.mtnsms.com; path=/\r\nCache-control: private\r\n\r\n<head><title>Object moved</title></head>\n<body><h1>Object Moved</h1>This object may be found <a HREF=\"http://www4.mtnsms.com/members/contacts/contacts.asp\">here</a>.</body>\n", 1535) = 699
                 if (g.debug)             Accept-Language: en\r\nUser-Agent: Lynx/2.8.4dev.7 libwww-FM/2.14\r\nReferer: http://www.mtnsms.com/\r\nCookie2: $Version=\"1\"\r\nCookie: 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
                         fprintf(stderr, "Setting Referer to '%s%s'\n",          *  }}} Cookies */
                                                                         host, file);          if (str != NULL) {
 #endif                  if (str == strstr("Set-Cookie: ", str)) {
                 free(www.referer);                          r->cookies = strdup(str + 13);
                 www.referer = (char *) malloc((strlen(host)+strlen(file)+7)*                  }
                                                                 sizeof(char));  
                 sprintf(www.referer, "http://%s%s", host, file);  
         }          }
 } // }}}  } // }}}
 // Function http_connect() {{{  // static http_connect(HTTP_REQUEST *r) {{{
 FILE *http_connect(void)  static FILE *http_connect(HTTP_REQUEST *r)
 {  {
         FILE *f;  
         int s = 0;          int s = 0;
         int i, idx = -1;          int i, idx = -1;
         struct sockaddr_in sockaddrIn;          struct sockaddr_in serv_addr;
           struct addrinfo *res0;
   
           memset((char *) &serv_addr, 0, sizeof(serv_addr));
           serv_addr.sin_family = AF_INET;
           serv_addr.sin_port = htons((unsigned short int) r->port);
   
           res0 = GetAddrInfo(r->host, r->port);
           if (res0 == NULL) {
                   fprintf(stderr, "Unable to locate remote host %s.", r->host);
                   return (NULL);
           }
   
         for (i=0; servers[i].desc != NULL; i++) {          for (i=0; servers[i].desc != NULL; i++) {
                 if (servers[i].id == id) {                  if (servers[i].id == id) {
Riadok 83  FILE *http_connect(void)
Riadok 108  FILE *http_connect(void)
                 fprintf(stderr, "Id %d not found in servers[] !\n", id);                  fprintf(stderr, "Id %d not found in servers[] !\n", id);
                 exit(1);                  exit(1);
         }          }
         sockaddrIn.sin_port = htons(servers[idx].port);          if (r->host == NULL)
         sockaddrIn.sin_family = AF_INET;                  serv_addr.sin_addr.s_addr = inet_addr(servers[idx].ip);
         sockaddrIn.sin_addr.s_addr = inet_addr(servers[idx].ip);          else
                   serv_addr.sin_addr.s_addr = inet_addr(r->host);
           if (serv_addr.sin_addr.s_addr == INADDR_NONE) {
                   struct hostent *pent = gethostbyname(r->host);
                   if (pent != NULL)
                           serv_addr.sin_addr.s_addr = *((u_long *) (pent->h_addr));
           }
           if (serv_addr.sin_addr.s_addr == INADDR_NONE)
                   return NULL;
   
         s = socket(PF_INET, SOCK_STREAM, 0);          s = socket(PF_INET, SOCK_STREAM, 0);
   
         if (s != -1) {          if (s != -1) {
                 for (i=0; i<MAX_CONNECTS; i++) {                  for (i=0; i<MAX_CONNECTS; i++) {
                         if (connect(s, (struct sockaddr *)&sockaddrIn,                          if (connect(s, (struct sockaddr *)&serv_addr,
                                                                                 sizeof(sockaddrIn)) != -1)                                                                                  sizeof(serv_addr)) != -1)
                                 break;                                  break;
                 }                  }
                 if ((f = fdopen(s, "w+b")) != NULL)                  if ((r->frw = fdopen(s, "w+b")) != NULL)
                         return (f);                          return (r->frw);
         }          }
         fprintf(stderr, "Can't connect to %s[%s]\n", servers[idx].desc,          fprintf(stderr, "Can't connect to %s[%s]\n", servers[idx].desc,
                                                         servers[idx].ip);                                                          servers[idx].ip);
   
         return(NULL);          return(NULL);
 } // }}}  } // }}}
 // Function http_read_source() {{{  // static void http_read_source(HTTP_REQUEST *r) {{{
 void http_read_source(FILE *f, char *host, char *file)  static void http_read_source(HTTP_REQUEST *r)
 {  {
         int search_for_link = 0;          int search_for_link = 0;
 #ifdef DEBUG  #ifdef DEBUG
         int info = g.debug;          int info = debug;
 #else  #else
         int info = 1;          int info = 1;
 #endif  #endif
           HTTP_REQUEST *new_r = NULL;
   
         while (1) {          while (1) {
                 char bla[1024];                  char bla[1024];
                 int i;  
   
                 if (fgets(bla, sizeof(bla), f) == NULL)                  if (fgets(bla, sizeof(bla), r->frw) == NULL)
                         break;                          break;
                   if (r->ret_val == NULL)
                           r->ret_val = strdup(bla);
                 if (search_for_link == 1) {  /* Handling " 302 Object Moved" */                  if (search_for_link == 1) {  /* Handling " 302 Object Moved" */
                         if (bla == strstr(bla, "Location: ")) {                          if (bla == strstr(bla, "Location: ")) {
                                 if ((g.goto_object_moved = strdup(bla)) == NULL) {                                  char *str;
   
                                   if ((str = strdup(bla)) == NULL) {
                                         fprintf(stderr, "strdup(%s) failed!\n", bla);                                          fprintf(stderr, "strdup(%s) failed!\n", bla);
                                         exit(1);                                          exit(1);
                                 }                                  }
                                 while (strlen(g.goto_object_moved) > 0 &&                                  while (strlen(str) > 0 && isspace(str[strlen(str) - 1]))
                                                                                 isspace(g.goto_object_moved[                                          str[strlen(str) - 1] = '\0';
                                                                                         strlen(g.goto_object_moved)  
                                                                                         - 1]))                                  new_r = new_request();
                                         g.goto_object_moved[                                  r->method = HTTP_GET;
                                                 strlen(g.goto_object_moved) - 1] = '\0';                                  if ((new_r->file = strstr((str + 17), "/")) != NULL) {
                                           new_r->host = (char *)
                                                   malloc ((new_r->file - str - 16)*sizeof(char));
                                           strncpy(new_r->host, (str + 17),
                                                                                           (new_r->file - str - 17));
                                   }
 #ifdef DEBUG  #ifdef DEBUG
                                 fprintf(stderr, "g.goto_object_moved = '%s'\n",                                  else {
                                                                                 g.goto_object_moved);                                          fprintf(stderr, "Invalid link '%s'!\n", str);
                                   }
                                   fprintf(stderr, "Object Moved  = '%s'\n", str);
 #endif  #endif
                                   free(str);
                                 search_for_link = 0;                                  search_for_link = 0;
                         }                          }
                 }                  }
Riadok 143  void http_read_source(FILE *f, char *hos
Riadok 188  void http_read_source(FILE *f, char *hos
                         info=0;                          info=0;
                         if (strstr(bla, "HTTP/1.") != NULL) {                          if (strstr(bla, "HTTP/1.") != NULL) {
                                 if ((bla+8) == strstr(bla, " 200 OK")) {                                  if ((bla+8) == strstr(bla, " 200 OK")) {
                                         http_set_referer(host, file);                                          //http_set_referer(host, file);
                                 }                                  }
                                 if ((bla+8) == strstr(bla, " 302 Object moved")) {                                  if ((bla+8) == strstr(bla, " 302 Object moved")) {
 #ifdef DEBUG  #ifdef DEBUG
Riadok 157  void http_read_source(FILE *f, char *hos
Riadok 202  void http_read_source(FILE *f, char *hos
                         }                          }
                 }                  }
 #ifdef DEBUG  #ifdef DEBUG
                 if (g.debug > 8 ) {                  if (debug > 8 ) {
                         fputs(bla, stderr);                          fputs(bla, stderr);
                 }                  }
 #endif  #endif
                 if (bla == strstr(bla, "Set-Cookie: "))                  if (bla == strstr(bla, "Set-Cookie: "))
                         http_set_cookie(bla);                          http_set_cookie(r, bla);
         }          }
 #ifdef DEBUG  #ifdef DEBUG
         if (search_for_link == 1) {          if (search_for_link == 1) {
                 fprintf(stderr, "Link NOT FOUND!\n");                  fprintf(stderr, "Link NOT FOUND!\n");
         }          }
 #endif  #endif
         fclose (f);          fclose (r->frw);
           if (new_r != NULL)
                   http_request_by_request(new_r);
   
 } // }}}  } // }}}
 // Function http_request() {{{  // int http_request_by_request(HTTP_REQUEST *r) {{{
   int http_request_by_request(HTTP_REQUEST *r)
   {
           return (http_request(r->method, r->file, r->host, NULL));
   } // }}}
   // int http_request(int method, char *file, char *host, char *fmt, ...) {{{
 int http_request(int method, char *file, char *host, char *fmt, ...)  int http_request(int method, char *file, char *host, char *fmt, ...)
 {  {
         FILE *f;  
         va_list ap;          va_list ap;
           HTTP_REQUEST *r;
   
           r = new_request();
   
           r->method = method;
           r->host = strdup(host);
           r->file = strdup(file);
           requests = add_to_requests(requests, r);
   
         if ((f=http_connect()) == NULL)          if ((r->frw = http_connect(r)) == NULL)
                 return(-1);                  return(-1);
 #ifdef DEBUG  #ifdef DEBUG
         if (g.debug) { // Debug code STAHUJEM/POSIELAM {{{          if (debug) { // Debug code STAHUJEM/POSIELAM {{{
                 if (method == HTTP_GET) {                  if (method == HTTP_GET) {
                         fprintf(stderr, "STAHUJEM: %s%s\n", host, file);                          fprintf(stderr, "GET: %s%s\n", host, file);
                 }                  }
                 else if (method == HTTP_POST) {                  else if (method == HTTP_POST) {
                         fprintf(stderr, "POSIELAM: %s%s\n", host, file);                          fprintf(stderr, "POST: %s%s\n", host, file);
                 }                  }
         } // }}}          } // }}}
 #endif  #endif
         if (method == HTTP_GET) {          switch (r->method) {
                 fprintf(f, "GET %s HTTP/1.0\r\n", file);                  case HTTP_GET:
         }                          fprintf(r->frw, "GET %s HTTP/1.0\r\n", file);
         else if (method == HTTP_POST) {                          break;
                 fprintf(f, "POST %s HTTP/1.0\r\n", file);                  case HTTP_POST:
         }                          fprintf(r->frw, "POST %s HTTP/1.0\r\n", file);
         else {                          break;
                 fprintf(stderr, "Unknown http method %d\n", method);                  default:
                 return(-1);                          fprintf(stderr, "Unknown http method %d\n", method);
                           break;
         }          }
         fprintf(f, "Host: %s\r\n", host);          fprintf(r->frw, "Host: %s\r\n", host);
         fprintf(f, "Accept: text/html, text/plain, application/applefile, ");          fprintf(r->frw, "Accept: text/html, text/plain, application/applefile, ");
         fprintf(f, "application/x-metamail-patch, sun-deskset-message, ");          fprintf(r->frw, "application/x-metamail-patch, sun-deskset-message, ");
         fprintf(f, "mail-file, default, postscript-file, audio-file, ");          fprintf(r->frw, "mail-file, default, postscript-file, audio-file, ");
         fprintf(f, "x-sun-attachment, text/enriched, text/richtext, ");          fprintf(r->frw, "x-sun-attachment, text/enriched, text/richtext, ");
         fprintf(f, "application/andrew-inset, x-be2\r\n");          fprintf(r->frw, "application/andrew-inset, x-be2\r\n");
         fprintf(f, "Accept: application/postscript, message/external-body, ");          fprintf(r->frw, "Accept: application/postscript, message/external-body, ");
         fprintf(f, "message/partial, image/g3fax, application/pdf, ");          fprintf(r->frw, "message/partial, image/g3fax, application/pdf, ");
         fprintf(f, "application/pgp, application/pgp, video/mpeg, video/*, ");          fprintf(r->frw, "application/pgp, application/pgp, video/mpeg, video/*, ");
         fprintf(f, "image/*, audio/mod, text/sgml, */*;q=0.01\r\n");          fprintf(r->frw, "image/*, audio/mod, text/sgml, */*;q=0.01\r\n");
         fprintf(f, "Accept-Encoding: gzip, compress\r\n");          fprintf(r->frw, "Accept-Encoding: gzip, compress\r\n");
         fprintf(f, "Accept-Language: en\r\n");          fprintf(r->frw, "Accept-Language: en\r\n");
   
         if (method == HTTP_POST) {          if (method == HTTP_POST) {
                 fprintf(f, "Pragma: no-cache\r\n");                  fprintf(r->frw, "Pragma: no-cache\r\n");
                 fprintf(f, "Cache-Control: no-cache\r\n");                  fprintf(r->frw, "Cache-Control: no-cache\r\n");
         }          }
         fprintf(f, "%s", USER_AGENT);          fprintf(r->frw, "%s", USER_AGENT);
         if (www.referer != NULL) fprintf(f, "Referer: %s\r\n", www.referer);          if (get_http_referer(requests) != NULL)
         if (www.cookies != NULL) {                  fprintf(r->frw, "Referer: %s\r\n", get_http_referer(requests));
           if (get_cookie(r) != NULL) {
 #ifdef DEBUG  #ifdef DEBUG
                 if (g.debug)                  if (debug)
                         fprintf(stderr, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n",                          fprintf(stderr, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n",
                                                                         www.cookies);                                                                          get_cookie(r));
 #endif  #endif
                 fprintf(f, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n",                  fprintf(r->frw, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n",
                                                                 www.cookies);                                                                  get_cookie(r));
         }          }
         if (fmt != NULL) {          if (fmt != NULL) {
                 va_start(ap, fmt);                  va_start(ap, fmt);
                 vfprintf(f, fmt, ap);                  vfprintf(r->frw, fmt, ap);
                 va_end(ap);                  va_end(ap);
         }          }
         fprintf(f, "\r\n");          fprintf(r->frw, "\r\n");
         http_read_source(f, host, file);          http_read_source(r);
           /*
         if (g.goto_object_moved != NULL) {          if (g.goto_object_moved != NULL) {
                 char *tmp_host;                  char *tmp_host;
                 char *tmp_file;                  char *tmp_file;
   
                 if ((tmp_file = strstr((g.goto_object_moved+17), "/")) != NULL) {                  if ((tmp_file = strstr((g.goto_object_moved+17), "/")) != NULL) {
                         tmp_host = (char *)                  tmp_host = (char *)
                                 malloc ((tmp_file-g.goto_object_moved-16)*sizeof(char));                  malloc ((tmp_file-g.goto_object_moved-16)*sizeof(char));
                         strncpy(tmp_host, (g.goto_object_moved+17),                  strncpy(tmp_host, (g.goto_object_moved+17),
                                                                         (tmp_file-g.goto_object_moved-17));                  (tmp_file-g.goto_object_moved-17));
                 if (g.goto_object_moved != NULL)                  my_free(g.goto_object_moved);
                         free(g.goto_object_moved);                  http_request(HTTP_GET, tmp_file, tmp_host, NULL);
                         http_request(HTTP_GET, tmp_file, tmp_host, NULL);                  my_free(tmp_host);
                         free(tmp_host);  
                 } else {                  } else {
 #ifdef DEBUG  #ifdef DEBUG
                         fprintf(stderr, "Invalid link '%s'!\n", g.goto_object_moved);  fprintf(stderr, "Invalid link '%s'!\n", g.goto_object_moved);
 #endif  #endif
                 }  }
                 if (g.goto_object_moved != NULL)  my_free(g.goto_object_moved);
                         free(g.goto_object_moved);  }
         }  */
 #ifdef DEBUG  #ifdef DEBUG
         if (g.debug) {          if (debug) {
                 fprintf(stderr, "HTTP request sent, reply OK...\n");                  fprintf(stderr, "HTTP request sent, reply OK...\n");
         }          }
 #endif  #endif
         return 0;  return 0;
   } // }}}
   // static void free_request(HTTP_REQUEST *r) {{{
   static void free_request(HTTP_REQUEST *r)
   {
           free(r->ret_val);
           free(r->host);
           free(r->file);
           free(r->cookies);
           free(r);
   }
   // }}}
   // static void free_requests(HTTP_REQUEST **req) {{{
   static void free_requests(HTTP_REQUEST **req)
   {
           register int i;
   
           for (i = 0; req[i] != NULL; i++)
                   free_request(req[i]);
   
           free(req);
   }
   // }}}
   // static int get_size_requests(HTTP_REQUEST **req) {{{
   static int get_size_requests(HTTP_REQUEST **req)
   {
           register int i;
   
           for (i = 0; req[i] != NULL; i++)
                   ;
   
           return i;
   } // }}}
   // static HTTP_REQUEST **create_requests(void) {{{
   static HTTP_REQUEST **create_requests(void)
   {
           register HTTP_REQUEST **req;
   
           if ((req = (HTTP_REQUEST **) malloc(1 * sizeof(HTTP_REQUEST *))) == NULL)
                   return NULL;
   
           req[0] = NULL;
   
           return req;
   } // }}}
   // static HTTP_REQUEST *new_request(void) {{{
   static HTTP_REQUEST *new_request(void)
   {
           HTTP_REQUEST *new;
   
           new = (HTTP_REQUEST *) malloc(1*sizeof(HTTP_REQUEST));
   
           return (new);
   } // }}}
   // static HTTP_REQUEST *duplicate_request(HTTP_REQUEST *r) {{{
   static HTTP_REQUEST *duplicate_request(HTTP_REQUEST *r)
   {
           HTTP_REQUEST *new;
   
           if( r == NULL)
                   return (NULL);
           if ((new = (HTTP_REQUEST *) malloc(1*sizeof(HTTP_REQUEST))) == NULL)
                   return (NULL);
   
           new->frw = r->frw;
           new->method = r->method;
           new->port = r->port;
           if (r->ret_val != NULL)
                   new->ret_val = strdup(r->ret_val);
           else
                   new->ret_val = NULL;
           if (r->host != NULL)
                   new->host = strdup(r->host);
           else
                   new->host = NULL;
           if (r->file != NULL)
                   new->file = strdup(r->file);
           else
                   new->file = NULL;
           if (r->cookies != NULL)
                   new->cookies = strdup(r->cookies);
           else
                   new->cookies = NULL;
   
           return (new);
   } // }}}
   // static HTTP_REQUEST **add_to_requests(HTTP_REQUEST **req, const HTTP_REQUEST *r) {{{
   static HTTP_REQUEST **add_to_requests(HTTP_REQUEST **req, const HTTP_REQUEST *r)
   {
           register int count;
   
           if (req == NULL)
                   if ((req = create_requests()) == NULL)
                           return NULL;
   
           count = get_size_requests(req);
   
           req = (HTTP_REQUEST **) realloc(req, (count + 2) * sizeof(HTTP_REQUEST *));
           if (req == NULL)
                   return NULL;
   
           req[count] = duplicate_request(r);
           req[count + 1] = NULL;
   
           return req;
 } // }}}  } // }}}
   // static char * get_http_referer(HTTP_REQUEST **req) {{{
   static char *get_http_referer(HTTP_REQUEST **req)
   {
           int count;
   
           count = get_size_requests(req);
   
           if (count > 0) {
                   return (req[count -1]->host);
           }
   
           return (NULL);
   }
   // }}}
   // static char * get_cookie(HTTP_REQUEST *r) {{{
   static char *get_cookie(HTTP_REQUEST *r)
   {
           int i;
           int count;
   
           count = get_size_requests(requests);
   #ifdef DEBUG
           fprintf(stderr, "count = %d in get_cookie()\n", count);
   #endif
           for (i=(count-1); i >= 0; i--) {
                   if (strcmp(requests[i]->host, r->host) == 0 &&
                                                                   r->cookies != NULL) {
                           r->cookies = requests[i]->cookies;
                           break;
                   }
           }
   
           return (r->cookies);
   }
   // }}}
   // void http_init(void) {{{
   void http_init(void)
   {
           if ((requests = create_requests()) == NULL) {
                   fprintf(stderr, "Failed creation of internal structures!\n");
                   exit(1);
           }
   
           return;
   }
   // }}}
 /* Modeline for ViM {{{1  /* Modeline for ViM {{{1
  * vim:set ts=4:   * vim:set ts=4:
  * vim600:fdm=marker fdl=0 fdc=3:   * vim600:fdm=marker fdl=0 fdc=3:
  * }}}1 */   * }}}1 */
   
   

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

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