From: helge Date: Sun, 24 Apr 2005 17:15:13 +0000 (+0000) Subject: fixed gcc 4.0 warnings X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f2d3c41e879808a85341c38842055a3fb1394b13;p=sope fixed gcc 4.0 warnings git-svn-id: http://svn.opengroupware.org/SOPE/trunk@768 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-appserver/NGObjWeb/Associations/WOKeyPathAssociation.m b/sope-appserver/NGObjWeb/Associations/WOKeyPathAssociation.m index 7131ec20..0146c488 100644 --- a/sope-appserver/NGObjWeb/Associations/WOKeyPathAssociation.m +++ b/sope-appserver/NGObjWeb/Associations/WOKeyPathAssociation.m @@ -122,7 +122,7 @@ typedef union { } WOSetMethodType; typedef struct { - char *ckey; + unsigned char *ckey; short keyLen:12; short isFault:1; WOKeyType type:3; @@ -269,8 +269,8 @@ _parseKeyPath(WOKeyPathAssociation *self,NSString *_keyPath) memcpy(info->ckey, cstr, info->keyLen); info->ckey[info->keyLen] = '\0'; - NSCAssert(strlen(info->ckey) > 0, @"invalid ckey .."); - NSCAssert((int)strlen(info->ckey) == (int)info->keyLen, + NSCAssert(strlen((char *)info->ckey) > 0, @"invalid ckey .."); + NSCAssert((int)strlen((char *)info->ckey) == (int)info->keyLen, @"size and content differ"); info->object = nil; @@ -396,7 +396,7 @@ static inline void _fillInfo(WOKeyPathAssociation *self, id object, method = class_get_instance_method(clazz, @selector(valueForBinding:)); info->type = WOKeyType_binding; info->extra.key = - [[StringClass alloc] initWithCString:(info->ckey + 1)]; + [[StringClass alloc] initWithCString:(char *)(info->ckey + 1)]; } else { if (object) { @@ -407,17 +407,17 @@ static inline void _fillInfo(WOKeyPathAssociation *self, id object, if (method != METHOD_NULL) { info->type = WOKeyType_kvc; info->extra.key = - [[StringClass alloc] initWithCString:info->ckey]; + [[StringClass alloc] initWithCString:(char *)info->ckey]; } else { - info->extra.sel.get = sel_get_uid(info->ckey); + info->extra.sel.get = sel_get_uid((char *)info->ckey); method = class_get_instance_method(clazz, info->extra.sel.get); if (method != METHOD_NULL) info->type = WOKeyType_method; } } else { - info->extra.sel.get = sel_get_uid(info->ckey); + info->extra.sel.get = sel_get_uid((char *)info->ckey); method = class_get_instance_method(clazz, info->extra.sel.get); if (method != METHOD_NULL) @@ -428,7 +428,7 @@ static inline void _fillInfo(WOKeyPathAssociation *self, id object, if (method != METHOD_NULL) { info->type = WOKeyType_kvc; info->extra.key = - [[StringClass alloc] initWithCString:info->ckey]; + [[StringClass alloc] initWithCString:(char *)info->ckey]; } } } @@ -437,10 +437,11 @@ static inline void _fillInfo(WOKeyPathAssociation *self, id object, method = class_get_class_method(object, @selector(valueForKey:)); if (method != METHOD_NULL) { info->type = WOKeyType_kvc; - info->extra.key = [[StringClass alloc] initWithCString:info->ckey]; + info->extra.key = + [[StringClass alloc] initWithCString:(char *)info->ckey]; } else { - info->extra.sel.get = sel_get_uid(info->ckey); + info->extra.sel.get = sel_get_uid((char *)info->ckey); method = class_get_class_method(*(Class *)object, info->extra.sel.get); if (method != METHOD_NULL) { @@ -756,9 +757,9 @@ static inline void _getSetSelName(register unsigned char *buf, } static inline SEL _getSetSel(register const unsigned char *_key, register unsigned _len) { - char buf[259]; + unsigned char buf[259]; _getSetSelName(buf, _key, _len); - return sel_get_uid(buf); + return sel_get_uid((char *)buf); } static BOOL _setValue(WOKeyPathAssociation *self, id _value, id root) { @@ -835,11 +836,11 @@ static BOOL _setValue(WOKeyPathAssociation *self, id _value, id root) { if ((clen = [_value cStringLength]) == 0) sm.strmethod(object, setSel, ""); else { - unsigned char *buf; + char *buf; buf = malloc(clen + 4); [_value getCString:buf]; buf[clen] = '\0'; sm.strmethod(object, setSel, buf); - if (buf) free(buf); + if (buf != NULL) free(buf); } } break; diff --git a/sope-appserver/NGObjWeb/ChangeLog b/sope-appserver/NGObjWeb/ChangeLog index 2d0016b9..f5f71e60 100644 --- a/sope-appserver/NGObjWeb/ChangeLog +++ b/sope-appserver/NGObjWeb/ChangeLog @@ -1,5 +1,12 @@ 2005-04-24 Helge Hess + * v4.5.155 + + * WOMailDelivery.m: generate \r\n instead of \n when writing to the + sendmail process + + * fixed gcc 4.0 warnings + * WOHttpAdaptor, WebDAV: fixed gcc 4.0 warnings (v4.5.154) * v4.5.153 diff --git a/sope-appserver/NGObjWeb/NGHttp+WO.m b/sope-appserver/NGObjWeb/NGHttp+WO.m index 6c354070..d19caa61 100644 --- a/sope-appserver/NGObjWeb/NGHttp+WO.m +++ b/sope-appserver/NGObjWeb/NGHttp+WO.m @@ -195,7 +195,7 @@ static Class NSArrayClass = Nil; return; } - cookieValue = [_cookie value]; + cookieValue = [(NGHttpCookie *)_cookie value]; if ([cookieValue isKindOfClass:[NSArray class]]) { if ([cookieValue count] == 0) cookieValue = @""; @@ -361,8 +361,8 @@ static Class DispClass = Nil; } p++; // skip the '?' - map = NGDecodeUrlFormParameters(p, strlen(p)); - if (uribuf) free(uribuf); uribuf = NULL; p = NULL; + map = NGDecodeUrlFormParameters((unsigned char *)p, strlen((char *)p)); + if (uribuf != NULL) free(uribuf); uribuf = NULL; p = NULL; if (map == nil) return formContent; diff --git a/sope-appserver/NGObjWeb/NGHttp/NGHttpBodyParser.m b/sope-appserver/NGObjWeb/NGHttp/NGHttpBodyParser.m index 1d9600f7..2fc3e200 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGHttpBodyParser.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGHttpBodyParser.m @@ -46,7 +46,7 @@ } if (len == 0) return nil; - body = NGDecodeUrlFormParameters(bytes, len); + body = NGDecodeUrlFormParameters((unsigned char *)bytes, len); return [body autorelease]; } diff --git a/sope-appserver/NGObjWeb/NGHttp/NGHttpHeaderFieldParser.m b/sope-appserver/NGObjWeb/NGHttp/NGHttpHeaderFieldParser.m index b2fe2118..4aebb227 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGHttpHeaderFieldParser.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGHttpHeaderFieldParser.m @@ -30,7 +30,7 @@ static Class NSArrayClass = Nil; - (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { unsigned len = 0; - const unsigned char *src = NULL; + const unsigned char *src = NULL; NGHttpHostHeaderField *value = nil; NSString *str = nil; @@ -40,7 +40,7 @@ static Class NSArrayClass = Nil; } else { len = [_data cStringLength]; - src = [_data cString]; + src = (const unsigned char *)[_data cString]; } if (len == 0) { #if DEBUG @@ -55,7 +55,7 @@ static Class NSArrayClass = Nil; len--; } - str = [[NSString alloc] initWithCString:src length:len]; + str = [[NSString alloc] initWithCString:(char *)src length:len]; NSAssert(str, @"string allocation failed .."); if ([_field isEqualToString:@"host"]) @@ -88,7 +88,7 @@ static Class NSArrayClass = Nil; } else { len = [_data cStringLength]; - src = [_data cString]; + src = (const unsigned char *)[_data cString]; } if (len == 0) { @@ -114,7 +114,7 @@ static Class NSArrayClass = Nil; src++; len--; } - scheme = [NSString stringWithCString:start length:(src - start)]; + scheme = [NSString stringWithCString:(char *)start length:(src - start)]; } // skip spaces @@ -167,7 +167,7 @@ static Class NSArrayClass = Nil; } else { len = [_data cStringLength]; - src = [_data cString]; + src = (const unsigned char *)[_data cString]; } if (len == 0) { @@ -213,7 +213,7 @@ static Class NSArrayClass = Nil; NSLog(@"field %@: current len=%i %s(%i)", _field, len, startPos, partLen); #endif - part = [self parseValuePart:startPos + part = [self parseValuePart:(const char *)startPos length:partLen zone:[array zone]]; if (part) { @@ -244,19 +244,19 @@ static Class NSArrayClass = Nil; @implementation NGHttpCharsetHeaderFieldParser -- (id)parseValue:(NSData *)_data ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { id value = nil; - value = [super parseValue:_data ofHeaderField:_field]; - if (value) { - if (NSArrayClass == Nil) - NSArrayClass = [NSArray class]; - - NSAssert([value isKindOfClass:NSArrayClass], @"invalid value .."); + if ((value = [super parseValue:_data ofHeaderField:_field]) == nil) + return nil; + + if (NSArrayClass == Nil) + NSArrayClass = [NSArray class]; - value = [[NGHttpCharsetHeaderField alloc] initWithArray:value]; - value = AUTORELEASE(value); - } + NSAssert([value isKindOfClass:NSArrayClass], @"invalid value .."); + + value = [[NGHttpCharsetHeaderField alloc] initWithArray:value]; + value = [value autorelease]; return value; } diff --git a/sope-appserver/NGObjWeb/NGHttp/NGHttpMessageParser.m b/sope-appserver/NGObjWeb/NGHttp/NGHttpMessageParser.m index 2938e379..98b30aa3 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGHttpMessageParser.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGHttpMessageParser.m @@ -234,25 +234,25 @@ static inline int _skipLWSP(NGHttpMessageParser *self, int _c) { bytes = [data mutableBytes]; /* strip trailing spaces ... */ - len = strlen(bytes); + len = strlen((char *)bytes); while (len > 0) { if (bytes[len - 1] != 32) break; len--; bytes[len] = '\0'; } - if ((tmp = rindex(bytes, 32))) { + if ((tmp = (unsigned char *)rindex((char *)bytes, 32))) { unsigned char *t2; - if ((t2 = strstr(tmp, "HTTP"))) { + if ((t2 = (unsigned char *)strstr((char *)tmp, "HTTP"))) { /* has a HTTP version spec ... */ *tmp = '\0'; tmp++; - self->version = [[NSString alloc] initWithCString:tmp]; + self->version = [[NSString alloc] initWithCString:(char *)tmp]; /* strip trailing spaces ... */ - len = strlen(bytes); + len = strlen((char *)bytes); while (len > 0) { if (bytes[len - 1] != 32) break; len--; @@ -263,7 +263,7 @@ static inline int _skipLWSP(NGHttpMessageParser *self, int _c) { /* has no HTTP version spec, but possibly trailing spaces */ /* strip trailing spaces ... */ - len = strlen(bytes); + len = strlen((char *)bytes); while (len > 0) { if (bytes[len - 1] != 32) break; len--; @@ -274,9 +274,9 @@ static inline int _skipLWSP(NGHttpMessageParser *self, int _c) { else { /* has no HTTP version spec */ } - self->uri = [[NSString alloc] initWithCString:bytes]; + self->uri = [[NSString alloc] initWithCString:(char *)bytes]; - RELEASE(data); data = nil; + [data release]; data = nil; } #if 0 @@ -508,7 +508,7 @@ static inline int _skipLWSP(NGHttpMessageParser *self, int _c) { return NO; } -- (NGMimeBodyParser *)parserForBodyOfPart:(id)_part +- (id)parserForBodyOfPart:(id)_part data:(NSData *)_dt { NGMimeType *contentType; diff --git a/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m b/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m index 28cac412..96b416da 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGHttpRequest.m @@ -103,12 +103,14 @@ NSString *methodNames[] = { - (NGHashMap *)uriParameters { // parameters in x-www-form-urlencoded encoding if (self->uriParameters == nil) { - const char *cstr = [self->uri cString]; - const char *pos = index(cstr, '?'); - - if (pos) { + const char *cstr; + const unsigned char *pos; + + cstr = [self->uri cString]; + pos = (const unsigned char *)index(cstr, '?'); + if (pos != NULL) { pos++; - self->uriParameters = NGDecodeUrlFormParameters(pos, strlen(pos)); + self->uriParameters = NGDecodeUrlFormParameters(pos, strlen((char*)pos)); } } return self->uriParameters; diff --git a/sope-appserver/NGObjWeb/NGHttp/NGUrlFormCoder.m b/sope-appserver/NGObjWeb/NGHttp/NGUrlFormCoder.m index 259cb6cf..1fa0159f 100644 --- a/sope-appserver/NGObjWeb/NGHttp/NGUrlFormCoder.m +++ b/sope-appserver/NGObjWeb/NGHttp/NGUrlFormCoder.m @@ -46,8 +46,9 @@ static __inline__ int _valueOfHexChar(unsigned char _c) { } static __inline__ unsigned -_unescapeUrl(const char *_src, unsigned _len, char *_dest) +_unescapeUrl(const unsigned char *_src, unsigned _len, unsigned char *_dest) { + // ODO: return Unicode? register unsigned i, i2; for (i = 0, i2 = 0; i < _len; i++, i2++) { @@ -79,13 +80,13 @@ static __inline__ NSString *urlStringFromBuffer(const unsigned char *buffer, { // TODO: we assume ISO-Latin-1/Unicode encoding, which might be wrong #if LIB_FOUNDATION_LIBRARY - return [[StrClass alloc] initWithCString:buffer length:len]; + return [[StrClass alloc] initWithCString:(char *)buffer length:len]; #else register signed int i; unichar *s; NSString *value; - s = malloc((len + 2) * sizeof(unichar)); + s = calloc((len + 2), sizeof(unichar)); for (i = len - 1; i >= 0; i--) s[i] = buffer[i]; value = [[StrClass alloc] initWithCharacters:s length:len]; @@ -113,13 +114,13 @@ NGHashMap *NGDecodeUrlFormParameters(const unsigned char *_buffer, do { NSString *key = nil, *value = nil; unsigned tmp, len; - char buffer[_len]; + unsigned char buffer[_len]; /* read key */ tmp = pos; while ((pos < _len) && (_buffer[pos] != '=')) pos++; - + len = _unescapeUrl(&(_buffer[tmp]), (pos - tmp), buffer); key = len > 0 ? urlStringFromBuffer(buffer, len) : @""; diff --git a/sope-appserver/NGObjWeb/NSObject+WO.m b/sope-appserver/NGObjWeb/NSObject+WO.m index 2f977c5d..64128f9f 100644 --- a/sope-appserver/NGObjWeb/NSObject+WO.m +++ b/sope-appserver/NGObjWeb/NSObject+WO.m @@ -129,7 +129,7 @@ static inline void _getSetSelName(register unsigned char *buf, static inline SEL _getSetSel(register const unsigned char *_key, register unsigned _len) { char buf[259]; - _getSetSelName(buf, _key, _len); + _getSetSelName((unsigned char *)buf, _key, _len); #if APPLE_RUNTIME || NeXT_RUNTIME return sel_getUid(buf); #else @@ -179,7 +179,7 @@ BOOL WOSetKVCValueUsingMethod(id object, NSString *_key, id _value) { buf = malloc(keyLen + 2); [_key getCString:buf]; - setSel = _getSetSel(buf, keyLen); + setSel = _getSetSel((unsigned char *)buf, keyLen); free(buf); buf = NULL; if (setSel == NULL) // no such selector diff --git a/sope-appserver/NGObjWeb/OWResourceManager.m b/sope-appserver/NGObjWeb/OWResourceManager.m index 944e7df8..589172b9 100644 --- a/sope-appserver/NGObjWeb/OWResourceManager.m +++ b/sope-appserver/NGObjWeb/OWResourceManager.m @@ -1111,9 +1111,7 @@ _pathExists(OWResourceManager *self, NSFileManager *fm, NSString *path) return (WOElement *)[cdef template]; } -- (WOComponent *)pageWithName:(NSString *)_name - languages:(NSArray *)_languages -{ +- (id)pageWithName:(NSString *)_name languages:(NSArray *)_languages { /* TODO: this appears to be deprecated since the WOComponent initializer is now -initWithContext: and we have no context here ... diff --git a/sope-appserver/NGObjWeb/SoObjects/SoSubContext.m b/sope-appserver/NGObjWeb/SoObjects/SoSubContext.m index ba9dd0ac..202ca891 100644 --- a/sope-appserver/NGObjWeb/SoObjects/SoSubContext.m +++ b/sope-appserver/NGObjWeb/SoObjects/SoSubContext.m @@ -87,7 +87,7 @@ - (void)setSession:(WOSession *)_session { [self logWithFormat:@"ignoring -setSession:%@ on sub-context", _session]; } -- (WOSession *)session { +- (id)session { return [[self parentContext] session]; } @@ -101,7 +101,7 @@ - (void)setPage:(WOComponent *)_page { [self logWithFormat:@"ignoring -setPage:%@ on sub-context", _page]; } -- (WOComponent *)page { +- (id)page { return [[self parentContext] page]; } diff --git a/sope-appserver/NGObjWeb/SoObjects/WODirectAction+SoObjects.m b/sope-appserver/NGObjWeb/SoObjects/WODirectAction+SoObjects.m index 74b78f4e..a62c186c 100644 --- a/sope-appserver/NGObjWeb/SoObjects/WODirectAction+SoObjects.m +++ b/sope-appserver/NGObjWeb/SoObjects/WODirectAction+SoObjects.m @@ -80,7 +80,7 @@ - (BOOL)isCallable { return YES; } -- (id)callOnObject:(id)_object inContext:(WOContext *)_ctx { +- (id)callOnObject:(id)_object inContext:(id)_ctx { return [_object ? _object : self->parent performActionNamed:self->daName]; } diff --git a/sope-appserver/NGObjWeb/WEClientCapabilities.m b/sope-appserver/NGObjWeb/WEClientCapabilities.m index ac3a820a..c6156dcc 100644 --- a/sope-appserver/NGObjWeb/WEClientCapabilities.m +++ b/sope-appserver/NGObjWeb/WEClientCapabilities.m @@ -88,8 +88,8 @@ - (id)initWithRequest:(WORequest *)_request { NSString *ac; - const unsigned char *ua; - const unsigned char *tmp; + const char *ua; + const char *tmp; int defaultOS = WEOS_UNKNOWN; int defaultCPU = WECPU_UNKNOWN; diff --git a/sope-appserver/NGObjWeb/WOApplication.m b/sope-appserver/NGObjWeb/WOApplication.m index 7685f4d8..3c5b7bd7 100644 --- a/sope-appserver/NGObjWeb/WOApplication.m +++ b/sope-appserver/NGObjWeb/WOApplication.m @@ -557,14 +557,14 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; unsigned char buf[20]; sessionCount++; - sprintf(buf, "%04X%04X%02X%08X", + sprintf((char *)buf, "%04X%04X%02X%08X", [[self number] intValue], getpid(), sessionCount, (unsigned int)time(NULL)); - wosid = [NSString stringWithCString:buf]; + wosid = [NSString stringWithCString:(char *)buf]; return wosid; } -- (WOSession *)createSessionForRequest:(WORequest *)_request { +- (id)createSessionForRequest:(WORequest *)_request { if ([self respondsToSelector:@selector(createSession)]) { /* call deprecated method */ [self warnWithFormat:@"calling deprecated -createSession .."]; @@ -580,9 +580,7 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; } } -- (WOSession *)restoreSessionWithID:(NSString *)_sid - inContext:(WOContext *)_ctx -{ +- (id)restoreSessionWithID:(NSString *)_sid inContext:(WOContext *)_ctx { WOSession *session; *(&session) = nil; @@ -753,7 +751,7 @@ static NSString *defaultCompRqHandlerClassName = @"WOComponentRequestHandler"; } } -- (WOSession *)session { +- (id)session { return [[self context] session]; } @@ -1034,7 +1032,7 @@ nbuckets, nindices, narrays, idxsize); return self->permanentPageCacheSize; } -- (WOComponent *)pageWithName:(NSString *)_name { +- (id)pageWithName:(NSString *)_name { // deprecated in WO4 return [self pageWithName:_name inContext:[self context]]; } @@ -1092,10 +1090,10 @@ nbuckets, nindices, narrays, idxsize); return [page autorelease]; } -- (WOComponent *)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx { +- (id)pageWithName:(NSString *)_name inContext:(WOContext *)_ctx { return [self _pageWithName:_name inContext:_ctx]; } -- (WOComponent *)pageWithName:(NSString *)_name forRequest:(WORequest *)_req { +- (id)pageWithName:(NSString *)_name forRequest:(WORequest *)_req { WOResourceManager *rm; if ((rm = [self resourceManager]) == nil) diff --git a/sope-appserver/NGObjWeb/WOChildComponentReference.m b/sope-appserver/NGObjWeb/WOChildComponentReference.m index 500e2a33..ef20f81f 100644 --- a/sope-appserver/NGObjWeb/WOChildComponentReference.m +++ b/sope-appserver/NGObjWeb/WOChildComponentReference.m @@ -78,7 +78,7 @@ static Class NSDateClass = Nil; return self->childName; } -- (WOElement *)template { +- (id)template { return self->template; } diff --git a/sope-appserver/NGObjWeb/WOComponent.m b/sope-appserver/NGObjWeb/WOComponent.m index 734e1131..efe54cc3 100644 --- a/sope-appserver/NGObjWeb/WOComponent.m +++ b/sope-appserver/NGObjWeb/WOComponent.m @@ -383,7 +383,7 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { return [@"/" stringByAppendingString:[self name]]; } -- (WOApplication *)application { +- (id)application { if (self->application == nil) return (self->application = [WOApplication application]); return self->application; @@ -398,7 +398,7 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { return nil; } -- (WOSession *)session { +- (id)session { if (self->session == nil) { if ((self->session = [[self context] session]) == nil) { [self debugWithFormat:@"could not get session object from context %@", @@ -449,7 +449,7 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { return (!self->componentFlags.reloadTemplates) ? YES : NO; } -- (WOComponent *)pageWithName:(NSString *)_name { +- (id)pageWithName:(NSString *)_name { NSArray *languages; WOResourceManager *rm; WOComponent *component; @@ -520,7 +520,7 @@ static inline id _getExtraVar(WOComponent *self, NSString *_key) { - (void)setParent:(WOComponent *)_parent { self->parentComponent = _parent; } -- (WOComponent *)parent { +- (id)parent { return self->parentComponent; } diff --git a/sope-appserver/NGObjWeb/WOContext.m b/sope-appserver/NGObjWeb/WOContext.m index aacc0599..cfe90458 100644 --- a/sope-appserver/NGObjWeb/WOContext.m +++ b/sope-appserver/NGObjWeb/WOContext.m @@ -98,7 +98,7 @@ static NSString *WOApplicationSuffix = nil; - (id)initWithRequest:(WORequest *)_request { if ((self = [super init])) { - unsigned char buf[24]; + char buf[24]; self->qpJoin = @"&"; sprintf(buf, "%03x%08x%08x", ++contextCount, (int)time(NULL), (int)self); @@ -292,7 +292,7 @@ static NSString *WOApplicationSuffix = nil; ASSIGN(self->session, _session); } -- (WOSession *)session { +- (id)session { // in WO4 -session creates a new session if none is associated if (self->session == nil) { @@ -364,7 +364,7 @@ static NSString *WOApplicationSuffix = nil; /* components */ -- (WOComponent *)component { +- (id)component { return (self->componentStackCount > 0) ? self->componentStack[self->componentStackCount - 1] : nil; @@ -374,7 +374,7 @@ static NSString *WOApplicationSuffix = nil; [_page ensureAwakeInContext:self]; ASSIGN(self->page, _page); } -- (WOComponent *)page { +- (id)page { return self->page; } @@ -985,12 +985,15 @@ void WOContext_leaveComponent(WOContext *self, WOComponent *_component) { /* DeprecatedMethodsInWO4 */ -- (WOApplication *)application { +- (id)application { if (self->application == nil) self->application = [WOAppClass application]; - if (self->application == nil) - NSLog(@"%s: missing application for context %@", __PRETTY_FUNCTION__, self); + if (self->application == nil) { + [self logWithFormat: + @"%s: missing application for context %@", + __PRETTY_FUNCTION__, self]; + } return self->application; } diff --git a/sope-appserver/NGObjWeb/WODirectAction.m b/sope-appserver/NGObjWeb/WODirectAction.m index 947f56bb..fa159822 100644 --- a/sope-appserver/NGObjWeb/WODirectAction.m +++ b/sope-appserver/NGObjWeb/WODirectAction.m @@ -71,11 +71,11 @@ return [[self context] request]; } -- (WOSession *)session { +- (id)session { return [[self context] session]; } -- (WOSession *)existingSession { +- (id)existingSession { WOContext *ctx = [self context]; /* check whether the context has a session */ @@ -179,7 +179,7 @@ /* pages */ -- (WOComponent *)pageWithName:(NSString *)_name { +- (id)pageWithName:(NSString *)_name { return [[WOApplication application] pageWithName:_name inContext:[self context]]; diff --git a/sope-appserver/NGObjWeb/WODynamicElement.m b/sope-appserver/NGObjWeb/WODynamicElement.m index bd74f22c..c1a7102e 100644 --- a/sope-appserver/NGObjWeb/WODynamicElement.m +++ b/sope-appserver/NGObjWeb/WODynamicElement.m @@ -219,7 +219,7 @@ static Class FormElementClass = Nil; self->extraAttributes = ea; } -- (WOElement *)template { +- (id)template { return nil; } diff --git a/sope-appserver/NGObjWeb/WOElement.m b/sope-appserver/NGObjWeb/WOElement.m index 236483ee..04dd92c8 100644 --- a/sope-appserver/NGObjWeb/WOElement.m +++ b/sope-appserver/NGObjWeb/WOElement.m @@ -213,11 +213,11 @@ static id numStrings[100]; @end /* WOElement(QueryString) */ NGObjWeb_DECLARE id OWGetProperty(NSDictionary *_set, NSString *_name) { - id propValue = [_set objectForKey:_name]; - - if (propValue) { - propValue = RETAIN(propValue); - [(id)_set removeObjectForKey:_name]; + register id propValue; + + if ((propValue = [_set objectForKey:_name]) != nil) { + propValue = [propValue retain]; + [(NSMutableDictionary *)_set removeObjectForKey:_name]; } return propValue; } diff --git a/sope-appserver/NGObjWeb/WOFileSessionStore.m b/sope-appserver/NGObjWeb/WOFileSessionStore.m index 0f36211f..9caf7763 100644 --- a/sope-appserver/NGObjWeb/WOFileSessionStore.m +++ b/sope-appserver/NGObjWeb/WOFileSessionStore.m @@ -156,9 +156,7 @@ static BOOL logExpire = YES; } } -- (WOSession *)restoreSessionWithID:(NSString *)_sid - request:(WORequest *)_request -{ +- (id)restoreSessionWithID:(NSString *)_sid request:(WORequest *)_request { NSAutoreleasePool *pool; NSString *snp; WOSession *session = nil; diff --git a/sope-appserver/NGObjWeb/WOHTTPConnection.m b/sope-appserver/NGObjWeb/WOHTTPConnection.m index 8cdc3da0..a6a5839a 100644 --- a/sope-appserver/NGObjWeb/WOHTTPConnection.m +++ b/sope-appserver/NGObjWeb/WOHTTPConnection.m @@ -256,17 +256,20 @@ static BOOL logStream = NO; [(NGActiveSocket *)self->socket setSendTimeout:[self sendTimeout]]; [(NGActiveSocket *)self->socket setReceiveTimeout:[self receiveTimeout]]; - if (self->socket) { - id bStr; - - bStr = [[NGBufferedStream alloc] initWithSource:self->socket]; - if (logStream) - self->log = [[WORecordRequestStream alloc] initWithSource:bStr]; + if (self->socket != nil) { + NGBufferedStream *bStr; + + bStr = [NGBufferedStream alloc]; // keep gcc happy + bStr = [bStr initWithSource:self->socket]; + if (logStream) { + self->log = [WORecordRequestStream alloc]; // keep gcc happy + self->log = [(WORecordRequestStream *)self->log initWithSource:bStr]; + } else self->log = nil; - self->io = - [[NGCTextStream alloc] initWithSource:(id)(self->log?self->log:bStr)]; + self->io = [NGCTextStream alloc]; // keep gcc happy + self->io = [self->io initWithSource:(id)(self->log ? self->log : bStr)]; [bStr release]; bStr = nil; } diff --git a/sope-appserver/NGObjWeb/WOMailDelivery.m b/sope-appserver/NGObjWeb/WOMailDelivery.m index e5b7c19c..ff35427a 100644 --- a/sope-appserver/NGObjWeb/WOMailDelivery.m +++ b/sope-appserver/NGObjWeb/WOMailDelivery.m @@ -127,8 +127,8 @@ WOMailDelivery *sharedInstance = nil; NSArray *to, *cc; FILE *toMail; - to = [_email objectForKey:@"to"]; - cc = [_email objectForKey:@"cc"]; + to = [(NSDictionary *)_email objectForKey:@"to"]; + cc = [(NSDictionary *)_email objectForKey:@"cc"]; [sendmail appendString:[[NSUserDefaults standardUserDefaults] stringForKey:@"WOSendMail"]]; @@ -137,55 +137,57 @@ WOMailDelivery *sharedInstance = nil; [sendmail appendString:@" "]; [sendmail appendString:[cc componentsJoinedByString:@" "]]; - if ((toMail = popen([sendmail cString], "w"))) { + if ((toMail = popen([sendmail cString], "w")) != NULL) { NSEnumerator *e = nil; id entry; NSString *tmp; - if ((tmp = [[_email objectForKey:@"from"] stringValue])) { - if (fprintf(toMail, "Reply-To: %s\n", [tmp cString]) < 0) + if ((tmp = [[(NSDictionary *)_email objectForKey:@"from"] stringValue])) { + if (fprintf(toMail, "Reply-To: %s\r\n", [tmp cString]) < 0) goto failed; - if (fprintf(toMail, "From: %s\n", [tmp cString]) < 0) + if (fprintf(toMail, "From: %s\r\n", [tmp cString]) < 0) goto failed; } e = [to objectEnumerator]; - while ((entry = [e nextObject])) { - if (fprintf(toMail, "To:%s\n", [[entry stringValue] cString]) < 0) + while ((entry = [e nextObject]) != nil) { + if (fprintf(toMail, "To:%s\r\n", [[entry stringValue] cString]) < 0) goto failed; } e = [cc objectEnumerator]; - while ((entry = [e nextObject])) { - if (fprintf(toMail, "Cc:%s\n", [[entry stringValue] cString]) < 0) + while ((entry = [e nextObject]) != nil) { + if (fprintf(toMail, "Cc:%s\r\n", [[entry stringValue] cString]) < 0) goto failed; } - if ((tmp = [[_email objectForKey:@"subject"] stringValue])) { - if (fprintf(toMail, "Subject:%s\n", [tmp cString]) < 0) + if ((tmp = [[(NSDictionary *)_email objectForKey:@"subject"] stringValue])) { + if (fprintf(toMail, "Subject:%s\r\n", [tmp cString]) < 0) goto failed; } - if ((tmp = [[_email objectForKey:@"content-type"] stringValue])) { - if (fprintf(toMail, "Content-type:%s\n", [tmp cString]) < 0) + if ((tmp = [[(NSDictionary *)_email objectForKey:@"content-type"] stringValue])) { + if (fprintf(toMail, "Content-type:%s\r\n", [tmp cString]) < 0) goto failed; } - if ((tmp = [[_email objectForKey:@"content-length"] stringValue])) { - if (fprintf(toMail, "Content-length:%s\n", [tmp cString]) < 0) + if ((tmp = [[(NSDictionary *)_email objectForKey:@"content-length"] stringValue])) { + if (fprintf(toMail, "Content-length:%s\r\n", [tmp cString]) < 0) goto failed; } - // end header - if (fprintf(toMail, "\n") < 0) + /* end header */ + if (fprintf(toMail, "\r\n") < 0) goto failed; - // write body + /* write body */ { - NSData *body = [_email objectForKey:@"body"]; + NSData *body; + + body = [(NSDictionary *)_email objectForKey:@"body"]; if (fwrite([body bytes], [body length], 1, toMail) < 0) goto failed; } - fprintf(toMail, "\n"); + fprintf(toMail, "\r\n"); pclose(toMail); return YES; diff --git a/sope-appserver/NGObjWeb/WOMessage.m b/sope-appserver/NGObjWeb/WOMessage.m index 6d6170f6..6756fa15 100644 --- a/sope-appserver/NGObjWeb/WOMessage.m +++ b/sope-appserver/NGObjWeb/WOMessage.m @@ -452,7 +452,7 @@ static __inline__ NSMutableData *_checkBody(WOMessage *self) { profile.appendC++; if (self->content == nil) _ensureBody(self); - if ((len = _value ? strlen(_value) : 0) == 0) + if ((len = _value ? strlen((char *)_value) : 0) == 0) return; switch (self->contentEncoding) { @@ -468,7 +468,7 @@ static __inline__ NSMutableData *_checkBody(WOMessage *self) { /* worst case ... */ NSString *s; - if ((s = [[NSString alloc] initWithCString:_value])) { + if ((s = [[NSString alloc] initWithCString:(char *)_value])) { self->addStr(self, @selector(appendContentString:), s); [s release]; } diff --git a/sope-appserver/NGObjWeb/WOProxyRequestHandler.m b/sope-appserver/NGObjWeb/WOProxyRequestHandler.m index 7e9a61cf..b3d260bd 100644 --- a/sope-appserver/NGObjWeb/WOProxyRequestHandler.m +++ b/sope-appserver/NGObjWeb/WOProxyRequestHandler.m @@ -90,7 +90,7 @@ if (_p) { printf("%s", [_p cString]); - if (fh) fprintf(fh, "%s", [_p cString]); + if (fh != NULL) fprintf(fh, "%s", [_p cString]); } /* headers */ @@ -100,24 +100,24 @@ id val; vals = [[_msg headersForKey:key] objectEnumerator]; - while ((val = [vals nextObject])) { - s = [[val stringValue] cString]; + while ((val = [vals nextObject]) != NULL) { + s = (unsigned char *)[[val stringValue] cString]; printf("%s: %s\n", [key cString], s); - if (fh) fprintf(fh, "%s: %s\r\n", [key cString], s); + if (fh != NULL) fprintf(fh, "%s: %s\r\n", [key cString], s); } } /* content */ - if ((s = [[_msg contentAsString] cString])) { + if ((s = (unsigned char *)[[_msg contentAsString] cString])) { printf("\n%s\n", s); - if (fh) fprintf(fh, "\r\n%s", s); + if (fh != NULL) fprintf(fh, "\r\n%s", s); } else { printf("\n"); - if (fh) fprintf(fh, "\r\n"); + if (fh != NULL) fprintf(fh, "\r\n"); } - if (fh) fclose(fh); + if (fh != NULL) fclose(fh); } - (void)logRequest:(WORequest *)_rq { diff --git a/sope-appserver/NGObjWeb/WOResourceManager.m b/sope-appserver/NGObjWeb/WOResourceManager.m index ce247324..9284a63e 100644 --- a/sope-appserver/NGObjWeb/WOResourceManager.m +++ b/sope-appserver/NGObjWeb/WOResourceManager.m @@ -203,7 +203,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path) return debugOn; } - (NSString *)loggingPrefix { - unsigned char buf[32]; + char buf[32]; sprintf(buf, "[wo-rm-0x%08X]", (unsigned)self); return [NSString stringWithCString:buf]; } @@ -1061,7 +1061,7 @@ _pathExists(WOResourceManager *self, NSFileManager *fm, NSString *path) return (WOElement *)[cdef template]; } -- (WOComponent *)pageWithName:(NSString *)_name languages:(NSArray *)_langs { +- (id)pageWithName:(NSString *)_name languages:(NSArray *)_langs { /* TODO: this appears to be deprecated since the WOComponent initializer is now -initWithContext: and we have no context over here ... diff --git a/sope-appserver/NGObjWeb/WOResourceRequestHandler.m b/sope-appserver/NGObjWeb/WOResourceRequestHandler.m index 61ed41fd..b6de8a20 100644 --- a/sope-appserver/NGObjWeb/WOResourceRequestHandler.m +++ b/sope-appserver/NGObjWeb/WOResourceRequestHandler.m @@ -156,11 +156,11 @@ static BOOL debugOn = NO; rmkey = [handlerPath objectAtIndex:0]; if ([rmkey length] > 0) { WOResourceManager *rm; - id data; + NSDictionary *data; rm = [[WOApplication application] resourceManager]; - if ((data = [rm _dataForKey:rmkey sessionID:nil])) { + if ((data = [rm _dataForKey:rmkey sessionID:nil]) != nil) { WOResponse *response; response = [WOResponse responseWithRequest:_request]; diff --git a/sope-appserver/NGObjWeb/WOResponse.m b/sope-appserver/NGObjWeb/WOResponse.m index 4df17b0e..f78997e6 100644 --- a/sope-appserver/NGObjWeb/WOResponse.m +++ b/sope-appserver/NGObjWeb/WOResponse.m @@ -82,7 +82,7 @@ static BOOL debugZip = NO; /* client caching */ -static __inline__ unsigned char *weekdayName(int dow) { +static __inline__ char *weekdayName(int dow) { switch (dow) { case 0: return "Sun"; case 1: return "Mon"; case 2: return "Tue"; case 3: return "Wed"; case 4: return "Thu"; case 5: return "Fri"; @@ -90,7 +90,7 @@ static __inline__ unsigned char *weekdayName(int dow) { default: return "UNKNOWN DAY OF WEEK !"; } } -static __inline__ unsigned char *monthName(int m) { +static __inline__ char *monthName(int m) { switch (m) { case 1: return "Jan"; case 2: return "Feb"; case 3: return "Mar"; case 4: return "Apr"; case 5: return "May"; case 6: return "Jun"; @@ -120,7 +120,7 @@ static __inline__ unsigned char *monthName(int m) { { NSCalendarDate *now; NSString *s; - unsigned char buf[32]; + char buf[32]; now = [[NSCalendarDate alloc] initWithTimeIntervalSinceNow:-3600.0]; [now setTimeZone:gmt]; diff --git a/sope-appserver/NGObjWeb/WOServerSessionStore.m b/sope-appserver/NGObjWeb/WOServerSessionStore.m index 84fc9e23..96647e8b 100644 --- a/sope-appserver/NGObjWeb/WOServerSessionStore.m +++ b/sope-appserver/NGObjWeb/WOServerSessionStore.m @@ -151,9 +151,7 @@ static BOOL logExpiredSessions = NO; [self->lock unlock]; } -- (WOSession *)restoreSessionWithID:(NSString *)_sid - request:(WORequest *)_request -{ +- (id)restoreSessionWithID:(NSString *)_sid request:(WORequest *)_request { WOSession *session = nil; if ([_sid length] == 0) diff --git a/sope-appserver/NGObjWeb/WOSession.m b/sope-appserver/NGObjWeb/WOSession.m index 30a96272..8c17d610 100644 --- a/sope-appserver/NGObjWeb/WOSession.m +++ b/sope-appserver/NGObjWeb/WOSession.m @@ -200,7 +200,7 @@ static Class NSDateClass = Nil; return self->isTerminating; } -- (WOApplication *)application { +- (id)application { if (self->application == nil) self->application = [WOApplication application]; return self->application; @@ -229,7 +229,7 @@ static Class NSDateClass = Nil; /* pages */ -- (WOComponent *)restorePageForContextID:(NSString *)_contextID { +- (id)restorePageForContextID:(NSString *)_contextID { unsigned short i; unsigned ctxHash; WOComponent *page = nil; diff --git a/sope-appserver/NGObjWeb/WOSessionStore.m b/sope-appserver/NGObjWeb/WOSessionStore.m index 5e1c5625..a941360a 100644 --- a/sope-appserver/NGObjWeb/WOSessionStore.m +++ b/sope-appserver/NGObjWeb/WOSessionStore.m @@ -49,9 +49,7 @@ /* checkin/out */ -- (WOSession *)checkOutSessionWithSessionID:(NSString *)_sid - request:(WORequest *)_request -{ +- (id)checkOutSessionWithSessionID:(NSString *)_sid request:(WORequest *)_rq { WOSession *session; *(&session) = nil; @@ -87,7 +85,7 @@ IS_DEPRECATED; [self saveSessionForContext:[_session context]]; } -- (WOSession *)restoreSessionWithID:(NSString *)_sid { +- (id)restoreSessionWithID:(NSString *)_sid { IS_DEPRECATED; return [self restoreSessionWithID:_sid request:nil]; } @@ -97,9 +95,7 @@ - (void)saveSessionForContext:(WOContext *)_context { [self subclassResponsibility:_cmd]; } -- (WOSession *)restoreSessionWithID:(NSString *)_sid - request:(WORequest *)_request -{ +- (id)restoreSessionWithID:(NSString *)_sid request:(WORequest *)_request { [self subclassResponsibility:_cmd]; return nil; } diff --git a/sope-appserver/NGObjWeb/WOSimpleHTTPParser.m b/sope-appserver/NGObjWeb/WOSimpleHTTPParser.m index dba94fa5..c76fb0cf 100644 --- a/sope-appserver/NGObjWeb/WOSimpleHTTPParser.m +++ b/sope-appserver/NGObjWeb/WOSimpleHTTPParser.m @@ -174,14 +174,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 @""; @@ -438,7 +438,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]; @@ -456,7 +456,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; } @@ -472,7 +472,7 @@ static NSString *stringForHeaderName(unsigned char *p) { } /* find key/value separator */ - if ((v = index(p, ':')) == NULL) { + if ((v = (unsigned char *)index((char *)p, ':')) == NULL) { [self warnWithFormat:@"got malformed header line: '%s'", self->lineBuffer]; continue; @@ -486,7 +486,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; @@ -494,11 +494,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) @@ -640,15 +640,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 +699,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 +867,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; diff --git a/sope-appserver/NGObjWeb/WOStatisticsStore.m b/sope-appserver/NGObjWeb/WOStatisticsStore.m index 8408c8b9..58b0d62d 100644 --- a/sope-appserver/NGObjWeb/WOStatisticsStore.m +++ b/sope-appserver/NGObjWeb/WOStatisticsStore.m @@ -49,7 +49,7 @@ @implementation WOStatisticsStore -static unsigned char *monthAbbr[13] = { +static char *monthAbbr[13] = { "Dec", "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" @@ -100,7 +100,7 @@ static id mkuint(unsigned int i) { } static id mkdbl(double d) { #if 1 - unsigned char buf[64]; + char buf[64]; sprintf(buf, "%.3f", d); return [NSStringClass stringWithCString:buf]; #else @@ -380,7 +380,7 @@ static id mkdbl(double d) { NSCalendarDate *now; NSDate *startDate; NSString *tmp; - unsigned char buf[64]; + char buf[64]; request = [_context request]; result = [NSMutableString stringWithCapacity:256]; diff --git a/sope-appserver/NGObjWeb/WOStats.m b/sope-appserver/NGObjWeb/WOStats.m index 5c95c358..ce3706cd 100644 --- a/sope-appserver/NGObjWeb/WOStats.m +++ b/sope-appserver/NGObjWeb/WOStats.m @@ -82,8 +82,9 @@ value = [NSNumber numberWithInt:[value intValue] * 1024]; } - if (d == nil) d = [NSMutableDictionary dictionary]; - [d setObject:value forKey:key]; + if (d == nil) + d = [NSMutableDictionary dictionaryWithCapacity:16]; + [(NSMutableDictionary *)d setObject:value forKey:key]; } } return d;