]> err.no Git - sope/blobdiff - sope-appserver/NGObjWeb/WOSimpleHTTPParser.m
bumped Xcode projects to version 4.7. Added a new Xcode project for the STXSaxDriver.
[sope] / sope-appserver / NGObjWeb / WOSimpleHTTPParser.m
index 595a8ecdf47ae813e5d0043e76892dc1ccb1cff3..184194fd316b463a9af3086c4a78a40fb474b1fb 100644 (file)
@@ -1,20 +1,20 @@
 /*
-  Copyright (C) 2000-2004 SKYRIX Software AG
+  Copyright (C) 2000-2005 SKYRIX Software AG
 
-  This file is part of OpenGroupware.org.
+  This file is part of SOPE.
 
-  OGo is free software; you can redistribute it and/or modify it under
+  SOPE is free software; you can redistribute it and/or modify it under
   the terms of the GNU Lesser General Public License as published by the
   Free Software Foundation; either version 2, or (at your option) any
   later version.
 
-  OGo is distributed in the hope that it will be useful, but WITHOUT ANY
+  SOPE is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
   License for more details.
 
   You should have received a copy of the GNU Lesser General Public
-  License along with OGo; see the file COPYING.  If not, write to the
+  License along with SOPE; see the file COPYING.  If not, write to the
   Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.
 */
@@ -23,6 +23,7 @@
 #include <NGObjWeb/WOResponse.h>
 #include <NGObjWeb/WORequest.h>
 #include "common.h"
+#include <string.h>
 
 @implementation WOSimpleHTTPParser
 
@@ -66,8 +67,9 @@ static int   maxUploadSize  = 0;
     self->readBytes = (void *)
       [(NSObject *)self->io methodForSelector:@selector(readBytes:count:)];
     if (self->readBytes == NULL) {
-      NSLog(@"WARNING(%s): got invalid stream object: %@", __PRETTY_FUNCTION__,
-           self->io);
+      [self warnWithFormat:@"(%s): got invalid stream object: %@",
+        __PRETTY_FUNCTION__,
+             self->io];
       [self release];
       return nil;
     }
@@ -132,9 +134,9 @@ static int   maxUploadSize  = 0;
        static BOOL didLog = NO;
        if (!didLog) {
          didLog = YES;
-         NSLog(@"WARNING(%s): reallocated the HTTP line buffer %i times, "
-               @"consider increasing the default line buffer size!",
-               __PRETTY_FUNCTION__, reallocCount);
+         [self warnWithFormat:@"(%s): reallocated the HTTP line buffer %i times, "
+            @"consider increasing the default line buffer size!",
+            __PRETTY_FUNCTION__, reallocCount];
        }
       }
       
@@ -173,14 +175,14 @@ static int   maxUploadSize  = 0;
 
 static NSString *ContentLengthHeaderName = @"content-length";
 
-static NSString *stringForHeaderName(unsigned char *p) {
+static NSString *stringForHeaderName(char *p) { /* Note: arg is _not_ const */
   /* 
      process header name
      
      we try to be smart to avoid creation of NSString objects ...
   */
   register unsigned len;
-  register unsigned char c1;
+  register char c1;
   
   if ((len = strlen(p)) == 0)
     return @"";
@@ -437,7 +439,7 @@ static NSString *stringForHeaderName(unsigned char *p) {
   {
     unsigned char *t;
     
-    for (t = p; *t != '\0'; t++)
+    for (t = (unsigned char *)p; *t != '\0'; t++)
       *t = tolower(*t);
   }
   return [[NSString alloc] initWithCString:p];
@@ -455,7 +457,7 @@ static NSString *stringForHeaderName(unsigned char *p) {
     if (heavyDebugOn)
       printf("read header line: '%s'\n", self->lineBuffer);
     
-    if (strlen(self->lineBuffer) == 0) {
+    if (strlen((char *)self->lineBuffer) == 0) {
       /* found end of header */
       break;
     }
@@ -464,16 +466,16 @@ static NSString *stringForHeaderName(unsigned char *p) {
     
     if (*p == ' ' || *p == '\t') {
       // TODO: implement folding (remember last header-key, add string)
-      [self logWithFormat:
-              @"ERROR(%s): got a folded HTTP header line, cannot process!",
-             __PRETTY_FUNCTION__];
+      [self errorWithFormat:
+              @"(%s): got a folded HTTP header line, cannot process!",
+              __PRETTY_FUNCTION__];
       continue;
     }
     
     /* find key/value separator */
-    if ((v = index(p, ':')) == NULL) {
-      [self logWithFormat:@"WARNING: got malformed header line: '%s'",
-             self->lineBuffer];
+    if ((v = (unsigned char *)index((char *)p, ':')) == NULL) {
+      [self warnWithFormat:@"got malformed header line: '%s'",
+              self->lineBuffer];
       continue;
     }
     
@@ -485,7 +487,7 @@ static NSString *stringForHeaderName(unsigned char *p) {
 
     if (*v != '\0') {
       /* trim trailing spaces */
-      for (idx = strlen(v) - 1; idx >= 0; idx--) {
+      for (idx = strlen((char *)v) - 1; idx >= 0; idx--) {
         if ((v[idx] != ' ' && v[idx] != '\t'))
           break;
         
@@ -493,11 +495,11 @@ static NSString *stringForHeaderName(unsigned char *p) {
       }
     }
     
-    headerName  = stringForHeaderName(p);
-    headerValue = [[NSStringClass alloc] initWithCString:v];
+    headerName  = stringForHeaderName((char *)p);
+    headerValue = [[NSStringClass alloc] initWithCString:(char *)v];
     
     if (headerName == ContentLengthHeaderName)
-      self->clen = atoi(v);
+      self->clen = atoi((char *)v);
     
     if (headerName != nil || headerValue != nil) {
       if (self->headers == nil)
@@ -541,9 +543,8 @@ static NSString *stringForHeaderName(unsigned char *p) {
        readToEOF = NO;
       
       if (readToEOF) {
-       [self logWithFormat:
-               @"WARNING: not processing entity of request "
-               @"without contentlen!"];
+        [self warnWithFormat:
+                @"not processing entity of request without contentlen!"];
       }
     }
   }
@@ -570,7 +571,7 @@ static NSString *stringForHeaderName(unsigned char *p) {
     fn = [[NSProcessInfo processInfo] temporaryFileName];
     
     if ((t = fopen([fn cString], "w")) == NULL) {
-      [self logWithFormat:@"ERROR: could not open temporary file '%@'!", fn];
+      [self errorWithFormat:@"could not open temporary file '%@'!", fn];
       
       /* read into memory as a fallback ... */
       
@@ -640,15 +641,15 @@ static NSString *stringForHeaderName(unsigned char *p) {
   //       body. The current implementation is far from optimal and only added
   //       for Mono compatibility (and actually produces the same behaviour
   //       like with HTTP/1.0 ...)
-  static unsigned char *contStatLine = 
+  static char *contStatLine = 
     "HTTP/1.0 100 Continue\r\n"
     "content-length: 0\r\n"
     "\r\n";
-  static unsigned char *failStatLine = 
+  static char *failStatLine = 
     "HTTP/1.0 417 Expectation Failed\r\n"
     "content-length: 0\r\n"
     "\r\n";
-  unsigned char *respline = NULL;
+  char *respline = NULL;
   BOOL ok = YES;
   
   [self debugWithFormat:@"process 100 continue on IO: %@", self->io];
@@ -699,11 +700,11 @@ static NSString *stringForHeaderName(unsigned char *p) {
   
   {
     /* sample line: "GET / HTTP/1.0" */
-    unsigned char *p, *t;
+    char *p, *t;
     
     /* parse method */
     
-    p = self->lineBuffer;
+    p = (char *)self->lineBuffer;
     if ((t = index(p, ' ')) == NULL) {
       [self logWithFormat:@"got broken request line '%s'", self->lineBuffer];
       return nil;
@@ -867,11 +868,11 @@ static NSString *stringForHeaderName(unsigned char *p) {
   
   {
     /* sample line: "HTTP/1.0 200 OK" */
-    unsigned char *p, *t;
+    char *p, *t;
     
     /* version */
     
-    p = self->lineBuffer;
+    p = (char *)self->lineBuffer;
     if ((t = index(p, ' ')) == NULL) {
       [self logWithFormat:@"got broken response line '%s'", self->lineBuffer];
       return nil;