From: helge Date: Sun, 24 Apr 2005 18:13:23 +0000 (+0000) Subject: fixed gcc 4.0 warnings X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7e417919194df24fe3dcc7cc9d85f693cdad8581;p=sope fixed gcc 4.0 warnings git-svn-id: http://svn.opengroupware.org/SOPE/trunk@770 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-mime/ChangeLog b/sope-mime/ChangeLog index 90118a35..5f4a7380 100644 --- a/sope-mime/ChangeLog +++ b/sope-mime/ChangeLog @@ -1,3 +1,7 @@ +2005-04-24 Helge Hess + + * NGMime, NGImap4, NGMail: fixed gcc 4.0 warnings (v4.5.220) + 2005-03-24 Helge Hess * NGMime, NGMail: fixed OGo bug #1324 by adding support for multivalue diff --git a/sope-mime/NGImap4/ChangeLog b/sope-mime/NGImap4/ChangeLog index f544c861..258d292c 100644 --- a/sope-mime/NGImap4/ChangeLog +++ b/sope-mime/NGImap4/ChangeLog @@ -1,3 +1,7 @@ +2005-04-24 Helge Hess + + * fixed gcc 4.0 warnings + 2005-03-24 Helge Hess * EOQualifier+IMAPAdditions.m: fixed a warning diff --git a/sope-mime/NGImap4/NGImap4Client.h b/sope-mime/NGImap4/NGImap4Client.h index aa679718..e3e7e6a4 100644 --- a/sope-mime/NGImap4/NGImap4Client.h +++ b/sope-mime/NGImap4/NGImap4Client.h @@ -128,8 +128,7 @@ typedef enum { - (NSDictionary *)unsubscribe:(NSString *)_name; - (NSDictionary *)expunge; -- (NSDictionary *)sort:(NSArray *)_sortOrderings - qualifier:(EOQualifier *)_qual +- (NSDictionary *)sort:(id)_sortOrderings qualifier:(EOQualifier *)_qual encoding:(NSString *)_encoding; - (NSDictionary *)fetchUids:(NSArray *)_uids parts:(NSArray *)_parts; - (NSDictionary *)fetchUid:(unsigned)_uid parts:(NSArray *)_parts; diff --git a/sope-mime/NGImap4/NGImap4Client.m b/sope-mime/NGImap4/NGImap4Client.m index 3995c095..71bf137b 100644 --- a/sope-mime/NGImap4/NGImap4Client.m +++ b/sope-mime/NGImap4/NGImap4Client.m @@ -1043,8 +1043,7 @@ static BOOL ImapDebugEnabled = NO; return [self->normer normalizeSortResponse:[self processCommand:sortStr]]; } -- (NSDictionary *)sort:(id)_sortSpec - qualifier:(EOQualifier *)_qual +- (NSDictionary *)sort:(id)_sortSpec qualifier:(EOQualifier *)_qual encoding:(NSString *)_encoding { /* @@ -1392,12 +1391,12 @@ static inline NSArray *_flags2ImapFlags(NGImap4Client *self, NSArray *_flags) { CountClient++; } -- (id)textStream { +- (NGCTextStream *)textStream { if (self->text == nil) { if ([self->context lastException] == nil) [self reconnect]; } - return self->text; + return (NGCTextStream *)self->text; } /* description */ diff --git a/sope-mime/NGImap4/NGImap4DataSource.h b/sope-mime/NGImap4/NGImap4DataSource.h index 76871a12..de7f968e 100644 --- a/sope-mime/NGImap4/NGImap4DataSource.h +++ b/sope-mime/NGImap4/NGImap4DataSource.h @@ -25,6 +25,15 @@ #import #import +/* + NGImap4DataSource + + Returned by the NGImap4FileManager when -dataSourceAtPath: is called. + + TODO: does this also handle subfolders? If not, we should rename the + datasource class (eg NGImap4MessageDataSource). +*/ + @class NSArray; @class NGImap4Folder; @class EOFetchSpecification; diff --git a/sope-mime/NGImap4/NGImap4FileManager.m b/sope-mime/NGImap4/NGImap4FileManager.m index fbfacb12..6377ef9b 100644 --- a/sope-mime/NGImap4/NGImap4FileManager.m +++ b/sope-mime/NGImap4/NGImap4FileManager.m @@ -33,11 +33,11 @@ password:(NSString *)_pwd host:(NSString *)_host; -- (NGImap4Folder *)_lookupFolderAtPath:(NSArray *)_paths; - -- (NGImap4Folder *)_lookupFolderAtPathString:(NSString *)_path; +- (id)_lookupFolderAtPath:(NSArray *)_paths; +- (id)_lookupFolderAtPathString:(NSString *)_path; - (EOQualifier *)_qualifierForFileName:(NSString *)_filename; + @end @implementation NGImap4FileManager @@ -169,9 +169,9 @@ static BOOL debugOn = NO; /* internals */ - (id)_lookupFolderAtPath:(NSArray *)_paths { + id folder; NSEnumerator *e; NSString *path; - id folder; folder = self->currentFolder; @@ -195,7 +195,7 @@ static BOOL debugOn = NO; return folder; } -- (NGImap4Folder *)_lookupFolderAtPathString:(NSString *)_path { +- (id)_lookupFolderAtPathString:(NSString *)_path { return [self _lookupFolderAtPath:[_path pathComponents]]; } @@ -208,7 +208,7 @@ static BOOL debugOn = NO; - (BOOL)createDirectoryAtPath:(NSString *)_path attributes:(NSDictionary *)_attributes { - NGImap4Folder *folder; + id folder; NSString *filename; if (![_path isAbsolutePath]) @@ -224,7 +224,7 @@ static BOOL debugOn = NO; } - (BOOL)changeCurrentDirectoryPath:(NSString *)_path { - NGImap4Folder *folder; + id folder; if ([_path length] == 0) return NO; @@ -270,7 +270,7 @@ static BOOL debugOn = NO; directories:(BOOL)_dirs files:(BOOL)_files { - NGImap4Folder *folder; + id folder; NSMutableArray *results; NSEnumerator *e; NGImap4Folder *tmp; @@ -310,7 +310,7 @@ static BOOL debugOn = NO; } - (NGImap4Message *)messageAtPath:(NSString *)_path { - NGImap4Folder *folder; + id folder; NSString *filename; EOQualifier *q; NSArray *msgs; @@ -346,8 +346,8 @@ static BOOL debugOn = NO; } - (NSData *)contentsAtPath:(NSString *)_path part:(NSString *)_part { - NSString *fileName; - NGImap4Folder *folder; + id folder; + NSString *fileName; if (![_path isAbsolutePath]) _path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path]; @@ -357,8 +357,12 @@ static BOOL debugOn = NO; if ((folder = [self _lookupFolderAtPath:[_path pathComponents]]) == nil) return nil; - - return [folder blobForUid:[fileName unsignedIntValue] part:_part]; + + if (![folder respondsToSelector:@selector(blobForUid:part:)]) + return nil; + + return [(NGImap4Folder *)folder blobForUid:[fileName unsignedIntValue] + part:_part]; } - (BOOL)fileExistsAtPath:(NSString *)_path { @@ -366,9 +370,9 @@ static BOOL debugOn = NO; return [self fileExistsAtPath:_path isDirectory:&isDir]; } - (BOOL)fileExistsAtPath:(NSString *)_path isDirectory:(BOOL *)_isDir { - NSArray *paths; - NSString *fileName; - NGImap4Folder *folder; + id folder; + NSArray *paths; + NSString *fileName; if (![_path isAbsolutePath]) _path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path]; @@ -539,7 +543,7 @@ static BOOL debugOn = NO; traverseLink:(BOOL)flag { NSString *fileName; - NGImap4Folder *folder, *sfolder; + id folder, sfolder; if (![_path isAbsolutePath]) _path = [[self currentDirectoryPath] stringByAppendingPathComponent:_path]; @@ -559,8 +563,12 @@ static BOOL debugOn = NO; if ((sfolder = [folder subFolderWithName:fileName caseInsensitive:NO])) return [self _fileAttributesOfFolder:sfolder]; - + /* check for messages */ + + if (![folder isKindOfClass:[NGImap4Folder class]]) + return nil; + { EOQualifier *q; NSArray *msgs; @@ -575,7 +583,7 @@ static BOOL debugOn = NO; } return [self _fileAttributesOfMessage:[msgs objectAtIndex:0] - inFolder:folder]; + inFolder:(NGImap4Folder *)folder]; } } @@ -614,12 +622,14 @@ static BOOL debugOn = NO; - (EODataSource *)dataSourceAtPath:(NSString *)_path { - NGImap4Folder *f; + id f; if ((f = [self _lookupFolderAtPath:[_path pathComponents]]) == nil) return nil; - - return [[[NGImap4DataSource alloc] initWithFolder:f] autorelease]; + + // TODO: check whether 'f' is really an NGImap4Folder? + return [[[NGImap4DataSource alloc] initWithFolder:(NGImap4Folder *)f] + autorelease]; } - (BOOL)syncMode { diff --git a/sope-mime/NGImap4/NGImap4Folder.m b/sope-mime/NGImap4/NGImap4Folder.m index 161c33ee..b0966d20 100644 --- a/sope-mime/NGImap4/NGImap4Folder.m +++ b/sope-mime/NGImap4/NGImap4Folder.m @@ -124,7 +124,7 @@ static int FetchNewUnseenMessagesInSubFoldersOnDemand = -1; #endif } -- (id)initWithContext:_context +- (id)initWithContext:(NGImap4Context *)_context name:(NSString *)_name flags:(NSArray *)_flags parentFolder:(id)_folder diff --git a/sope-mime/NGImap4/NGImap4Message.m b/sope-mime/NGImap4/NGImap4Message.m index 661349ac..40b2ef78 100644 --- a/sope-mime/NGImap4/NGImap4Message.m +++ b/sope-mime/NGImap4/NGImap4Message.m @@ -31,6 +31,8 @@ #include "NGImap4Message+BodyStructure.h" +@class NSNotification; + @interface NGImap4Message(Internals) - (void)initializeMessage; @@ -39,8 +41,8 @@ - (void)generateBodyStructure; - (NSString *)_addFlagNotificationName; - (NSString *)_removeFlagNotificationName; -- (void)_removeFlag:(id)_obj; -- (void)_addFlag:(id)_obj; +- (void)_removeFlag:(NSNotification *)_obj; +- (void)_addFlag:(NSNotification *)_obj; - (void)setIsRead:(BOOL)_isRead; @end /* NGImap4Message(Internals) */ diff --git a/sope-mime/NGImap4/NGImap4ResponseParser.m b/sope-mime/NGImap4/NGImap4ResponseParser.m index 561f247d..270a59c6 100644 --- a/sope-mime/NGImap4/NGImap4ResponseParser.m +++ b/sope-mime/NGImap4/NGImap4ResponseParser.m @@ -63,7 +63,7 @@ static __inline__ int _la(NGImap4ResponseParser *self, unsigned _laCnt) { : c; } static __inline__ BOOL _matchesString(NGImap4ResponseParser *self, - unsigned char *s) + const char *s) { register unsigned int i; diff --git a/sope-mime/NGImap4/NGImap4ServerRoot.m b/sope-mime/NGImap4/NGImap4ServerRoot.m index ed486298..4b58acef 100644 --- a/sope-mime/NGImap4/NGImap4ServerRoot.m +++ b/sope-mime/NGImap4/NGImap4ServerRoot.m @@ -154,7 +154,7 @@ static int FetchNewUnseenMessagesInSubFoldersOnDemand = -1; return _subFolderWithName(self, _name, _caseIns); } -- (id)parentFolder { +- (NGImap4Folder *)parentFolder { return nil; } @@ -355,11 +355,11 @@ static int FetchNewUnseenMessagesInSubFoldersOnDemand = -1; return _deleteSubFolder(self, _folder); } -- (BOOL)copySubFolder:(NGImap4Folder *)_f to:(id)_folder { +- (BOOL)copySubFolder:(NGImap4Folder *)_f to:(NGImap4Folder *)_folder { return _copySubFolder(self, _f, _folder); } -- (BOOL)moveSubFolder:(NGImap4Folder *)_f to:(id)_folder { +- (BOOL)moveSubFolder:(NGImap4Folder *)_f to:(NGImap4Folder *)_folder { return _moveSubFolder(self, _f, _folder); } diff --git a/sope-mime/NGImap4/NGSieveClient.m b/sope-mime/NGImap4/NGSieveClient.m index 547c23ae..94baaca4 100644 --- a/sope-mime/NGImap4/NGSieveClient.m +++ b/sope-mime/NGImap4/NGSieveClient.m @@ -223,8 +223,9 @@ static BOOL debugImap4 = NO; [self logWithFormat:@"ERROR: could not connect: %@", self->address]; return nil; } - - self->io = [[NGBufferedStream alloc] initWithSource:(id)self->socket]; + + self->io = [NGBufferedStream alloc]; // keep gcc happy + self->io = [self->io initWithSource:(id)self->socket]; self->parser = [[NGImap4ResponseParser alloc] initWithStream:self->socket]; /* receive greeting from server without tag-id */ @@ -284,7 +285,7 @@ static BOOL debugImap4 = NO; int bufLen, logLen; if (![self->socket isConnected]) { - id con; + NSDictionary *con; if ((con = [self openConnection]) == nil) return nil; @@ -531,7 +532,7 @@ static BOOL debugImap4 = NO; forKeys:keys count:2]; } -- (NSDictionary *)normalizeOpenConnectionResponse:(NGHashMap *)_map { +- (NSMutableDictionary *)normalizeOpenConnectionResponse:(NGHashMap *)_map { /* filter for open connection */ NSMutableDictionary *result; NSString *tmp; @@ -744,7 +745,7 @@ static BOOL debugImap4 = NO; countBuf[i] = c; } countBuf[i] = '\0'; - byteCount = i > 0 ? atoi(countBuf) : 0; + byteCount = i > 0 ? atoi((char *)countBuf) : 0; /* read CRLF */ @@ -768,7 +769,7 @@ static BOOL debugImap4 = NO; } octets[byteCount] = '\0'; - return [[NSString alloc] initWithUTF8String:octets]; + return [[NSString alloc] initWithUTF8String:(char *)octets]; } - (NSString *)readQuoted { @@ -792,7 +793,7 @@ static BOOL debugImap4 = NO; if (c == -1) return nil; - return [[NSString alloc] initWithUTF8String:buf]; + return [[NSString alloc] initWithUTF8String:(char *)buf]; } - (NSString *)readStringToCRLF { @@ -825,7 +826,7 @@ static BOOL debugImap4 = NO; } } - return [[NSString alloc] initWithUTF8String:buf]; + return [[NSString alloc] initWithUTF8String:(char *)buf]; } - (NSString *)readString { diff --git a/sope-mime/NGImap4/NSString+Imap4.m b/sope-mime/NGImap4/NSString+Imap4.m index f6fe914d..76594791 100644 --- a/sope-mime/NGImap4/NSString+Imap4.m +++ b/sope-mime/NGImap4/NSString+Imap4.m @@ -27,7 +27,7 @@ static void _encodeToModifiedUTF7(unsigned char *_buf, int encLen, unsigned char **result_, unsigned int *cntRes_); -static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, +static int _decodeOfModifiedUTF7(unsigned char *_target, unsigned _targetLen, unsigned *usedBytes_ , unsigned char **buffer_, int *bufLen_, int maxBuf); @@ -48,7 +48,7 @@ static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, res = calloc((len * 6) + 3, sizeof(char)); buf[len] = '\0'; res[len * 6] = '\0'; - [self getCString:buf]; + [self getCString:(char *)buf]; while (cnt < len) { int c = buf[cnt]; @@ -94,9 +94,9 @@ static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, } } } - result = [[NSString alloc] initWithCStringNoCopy:res - length:cntRes - freeWhenDone:YES]; + result = [[NSString alloc] initWithCStringNoCopy:(char *)res + length:cntRes + freeWhenDone:YES]; free(buf); buf = NULL; return [result autorelease]; } @@ -118,7 +118,7 @@ static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, buf[len] = '\0'; res[len] = '\0'; - [self getCString:buf]; + [self getCString:(char *)buf]; while (cnt < (len - 1)) { /* &- */ unsigned char c; @@ -164,32 +164,34 @@ static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, if (cnt < len) res[cntRes++] = buf[cnt++]; - result = [[NSString alloc] initWithCStringNoCopy:res + result = [[NSString alloc] initWithCStringNoCopy:(char *)res length:cntRes freeWhenDone:YES]; - free(buf); buf = NULL; + if (buf) free(buf); buf = NULL; return [result autorelease]; } - (NSString *)stringByEscapingImap4Password { - // TODO: Unicode, perf - unsigned char *buffer; - const unsigned char *chars; - unsigned len, i, j; - - len = [self cStringLength]; - chars = [self cString]; - - buffer = calloc(len * 2 + 2, sizeof(char)); + // TODO: perf + unichar *buffer; + unichar *chars; + unsigned len, i, j; + NSString *s; + + len = [self length]; + chars = calloc(len + 2, sizeof(unichar)); + [self getCharacters:chars]; + + buffer = calloc(len * 2 + 2, sizeof(unichar)); buffer[len * 2] = '\0'; - + for (i = 0, j = 0; i < len; i++, j++) { BOOL conv = NO; if (chars[i] <= 0x1F || chars[i] > 0x7F) { conv = YES; } - switch (chars[i]) { + else switch (chars[i]) { case '(': case ')': case '{': @@ -199,16 +201,20 @@ static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, case '"': case '\\': conv = YES; + break; } - + if (conv) { - buffer[j++] = '\\'; + buffer[j] = '\\'; + j++; } buffer[j] = chars[i]; - } + } + if (chars != NULL) free(chars); chars = NULL; - return [[(NSString *)[NSString alloc] - initWithCString:buffer length:j] autorelease]; + s = [NSString stringWithCharacters:buffer length:j]; + if (buffer != NULL) free(buffer); buffer = NULL; + return s; } @end /* NSString(Imap4) */ @@ -308,7 +314,7 @@ static char index_64[128] = { #define char64(c) (((c) < 0 || (c) > 127) ? -1 : index_64[(c)]) -static int _decodeOfModifiedUTF7(char *_target, unsigned _targetLen, +static int _decodeOfModifiedUTF7(unsigned char *_target, unsigned _targetLen, unsigned *usedBytes_ , unsigned char **buffer_, int *bufLen_, int maxBuf) { diff --git a/sope-mime/NGMail/ChangeLog b/sope-mime/NGMail/ChangeLog index e1ef34ce..8c3da6c0 100644 --- a/sope-mime/NGMail/ChangeLog +++ b/sope-mime/NGMail/ChangeLog @@ -1,3 +1,7 @@ +2005-04-24 Helge Hess + + * fixed gcc 4.0 warnings + 2005-03-24 Helge Hess * NGMimeMessageGenerator.m: mark To, Cc and Bcc as multivalue header diff --git a/sope-mime/NGMail/NGMailAddressParser.m b/sope-mime/NGMail/NGMailAddressParser.m index bd90f2fc..ecef01c8 100644 --- a/sope-mime/NGMail/NGMailAddressParser.m +++ b/sope-mime/NGMail/NGMailAddressParser.m @@ -52,7 +52,8 @@ static NSNumber *yesNum = nil; } static inline NSString *mkStrObj(const unsigned char *s, unsigned int l) { - return [(NSString *)[StrClass alloc] initWithCString:s length:l]; + // TODO: unicode + return [(NSString *)[StrClass alloc] initWithCString:(char *)s length:l]; } static inline id parseWhiteSpaces(NGMailAddressParser *self, BOOL _guessMode) { @@ -82,7 +83,7 @@ static inline id parseAtom(NGMailAddressParser *self, BOOL _guessMode) { int keepPos = self->dataPos; // keep reference for backtracking id returnValue = nil; BOOL isAtom = YES; - char text[self->maxLength]; // token text + unsigned char text[self->maxLength + 2]; // token text int length = 0; // token text length BOOL done = NO; @@ -160,7 +161,7 @@ static inline id parseQText(NGMailAddressParser *self, BOOL _guessMode) { int keepPos = self->dataPos; // keep reference for backtracking id returnValue = nil; BOOL isQText = YES; - char text[self->maxLength]; // token text + unsigned char text[self->maxLength + 4]; // token text int length = 0; // token text length BOOL done = YES; @@ -213,7 +214,7 @@ static inline id parseDText(NGMailAddressParser *self, BOOL _guessMode) { int keepPos = self->dataPos; // keep reference for backtracking id returnValue = nil; BOOL isDText = YES; - char text[self->maxLength]; // token text + unsigned char text[self->maxLength]; // token text int length = 0; // token text length BOOL done = YES; @@ -317,23 +318,19 @@ static inline id parseDomainLiteral(NGMailAddressParser *self, BOOL _guessMode) /* constructors */ -+ (id)mailAddressParserWithString:(NSString *)_string { - return [[(NGMailAddressParser *)[self alloc] - initWithCString:[_string cString] - length:[_string cStringLength]] autorelease]; -} + (id)mailAddressParserWithData:(NSData *)_data { return [[(NGMailAddressParser *)[self alloc] - initWithCString:(char *)[_data bytes] + initWithCString:[_data bytes] length:[_data length]] autorelease]; } + (id)mailAddressParserWithCString:(char *)_cString { return [[(NGMailAddressParser *)[self alloc] - initWithCString:_cString + initWithCString:(unsigned char *)_cString length:strlen(_cString)] autorelease]; } - (id)initWithCString:(const unsigned char *)_cstr length:(int unsigned)_len { if ((self = [super init])) { + // TODO: remember some string encoding? self->data = (unsigned char *)_cstr; self->maxLength = _len; self->dataPos = 0; @@ -341,10 +338,22 @@ static inline id parseDomainLiteral(NGMailAddressParser *self, BOOL _guessMode) } return self; } + +- (id)initWithString:(NSString *)_str { + // TODO: unicode + return [self initWithCString:(unsigned char *)[_str cString] + length:[_str cStringLength]]; +} + - (id)init { return [self initWithCString:NULL length:0]; } ++ (id)mailAddressParserWithString:(NSString *)_string { + return [[(NGMailAddressParser *)[self alloc] initWithString:_string] + autorelease]; +} + - (void)dealloc { self->data = NULL; self->maxLength = 0; diff --git a/sope-mime/NGMail/NGMimeMessageGenerator.m b/sope-mime/NGMail/NGMimeMessageGenerator.m index 736a9da1..e3e6101d 100644 --- a/sope-mime/NGMail/NGMimeMessageGenerator.m +++ b/sope-mime/NGMail/NGMimeMessageGenerator.m @@ -126,8 +126,9 @@ static BOOL debugOn = NO; // memcpy(des, bytes, cnt); memcpy(des, iso, isoLen); - desLen = NGEncodeQuotedPrintableMime(bytes, length, - des + isoLen, desLen - isoLen); + desLen = NGEncodeQuotedPrintableMime((unsigned char *)bytes, length, + (unsigned char *)(des + isoLen), + desLen - isoLen); if ((int)desLen != -1) { memcpy(des + isoLen + desLen, isoEnd, isoEndLen); diff --git a/sope-mime/NGMail/NGMimeMessageParser.m b/sope-mime/NGMail/NGMimeMessageParser.m index c373c151..e883a872 100644 --- a/sope-mime/NGMail/NGMimeMessageParser.m +++ b/sope-mime/NGMail/NGMimeMessageParser.m @@ -37,7 +37,7 @@ static Class NGMimeMessageParserClass = NULL; if (UseFoundationStringEncodingForMimeHeader == -1) { UseFoundationStringEncodingForMimeHeader = [[NSUserDefaults standardUserDefaults] - boolForKey:@"UseFoundationStringEncodingForMimeHeader"] + boolForKey:@"UseFoundationStringEncodingForMimeHeader"] ? 1 : 0; } if (NGMimeMessageParserClass == NULL) { @@ -45,25 +45,26 @@ static Class NGMimeMessageParserClass = NULL; } } -- (id)parser:(id)_parser parseHeaderField:(NSString *)_field data:(NSData *)_data +- (id)parser:(NGMimePartParser *)_p parseHeaderField:(NSString *)_field + data:(NSData *)_data { - id v = nil; + NGMimeMessageParser *parser = nil; + id v; - if ([_parser isKindOfClass:NGMimeMessageParserClass] == NO) { - NGMimeMessageParser *parser = nil; - - parser = [[NGMimeMessageParserClass alloc] init]; - v = [parser valueOfHeaderField:_field data:_data]; - [parser release]; parser = nil; - } + if ([_p isKindOfClass:NGMimeMessageParserClass]) + return nil; + + parser = [[NGMimeMessageParserClass alloc] init]; + v = [parser valueOfHeaderField:_field data:_data]; + [parser release]; parser = nil; return v; } - (id)parser:(NGMimePartParser *)_parser bodyParserForPart:(id)_part { - id ctype; - NGMimeType *contentType; + id ctype; + NGMimeType *contentType; ctype = [_part contentType]; @@ -210,7 +211,8 @@ static Class NSStringClass = Nil; if (bytes[cnt] == '?') { charset = - [NSStringClass stringWithCString:(bytes + tmp) length:cnt - tmp]; + [NSStringClass stringWithCString:(char *)(bytes + tmp) + length:(cnt - tmp)]; tmp = -1; if ((length - cnt) > 2) { @@ -236,7 +238,7 @@ static Class NSStringClass = Nil; NSString *tmpStr; unsigned int tmpLen; - tmpData = _rfc2047Decoding(encoding, bytes + tmp, cnt - tmp); + tmpData = _rfc2047Decoding(encoding, (char *)bytes + tmp, cnt - tmp); foundQP = YES; /* diff --git a/sope-mime/NGMime/ChangeLog b/sope-mime/NGMime/ChangeLog index 5e02edef..47664137 100644 --- a/sope-mime/NGMime/ChangeLog +++ b/sope-mime/NGMime/ChangeLog @@ -1,3 +1,7 @@ +2005-04-24 Helge Hess + + * fixed gcc 4.0 warnings + 2005-03-24 Helge Hess * NGMimePartGenerator.m: minor improvement in field generation API, diff --git a/sope-mime/NGMime/NGMimeAddressHeaderFieldGenerator.m b/sope-mime/NGMime/NGMimeAddressHeaderFieldGenerator.m index 21d67962..87becd90 100644 --- a/sope-mime/NGMime/NGMimeAddressHeaderFieldGenerator.m +++ b/sope-mime/NGMime/NGMimeAddressHeaderFieldGenerator.m @@ -106,7 +106,7 @@ static int UseLFSeperatedAddressEntries = -1; unsigned desLen; unsigned char *des; - if (buffer) free(buffer); + if (buffer != NULL) free(buffer); buffer = NULL; { NSData *data; @@ -127,12 +127,12 @@ static int UseLFSeperatedAddressEntries = -1; memcpy(des, buffer, cnt); memcpy(des + cnt, iso, isoLen); desLen = - NGEncodeQuotedPrintableMime(buffer + cnt, bufLen - cnt, + NGEncodeQuotedPrintableMime((unsigned char *)buffer + cnt, bufLen- cnt, des + cnt + isoLen, desLen - cnt - isoLen); if ((int)desLen != -1) { memcpy(des + cnt + isoLen + desLen, isoEnd, isoEndLen); - tmp = [NSString stringWithCString:des + tmp = [NSString stringWithCString:(char *)des length:(cnt + isoLen + desLen + isoEndLen)]; } else { diff --git a/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m b/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m index 14d2d2d1..af429b58 100644 --- a/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m +++ b/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldGenerator.m @@ -63,7 +63,7 @@ // TODO: unicode? len = [tmp cStringLength]; ctmp = malloc(len + 3); - [tmp getCString:ctmp]; ctmp[len] = '\0'; + [tmp getCString:(char *)ctmp]; ctmp[len] = '\0'; cnt = 0; doEnc = NO; while (cnt < len) { @@ -102,9 +102,9 @@ memcpy(des, ctmp, cnt); memcpy(des + cnt, iso, isoLen); desLen = - NGEncodeQuotedPrintableMime(ctmp + cnt, len - cnt, - des + cnt + isoLen, - desLen - cnt - isoLen); + NGEncodeQuotedPrintableMime((unsigned char *)ctmp + cnt, len - cnt, + (unsigned char *)des + cnt + isoLen, + desLen - cnt - isoLen); if ((int)desLen != -1) { memcpy(des + cnt + isoLen + desLen, isoEnd, isoEndLen); [data appendBytes:des length:(cnt + isoLen + desLen + isoEndLen)]; diff --git a/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldParser.m b/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldParser.m index 38d27048..fe37078b 100644 --- a/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeContentDispositionHeaderFieldParser.m @@ -37,9 +37,9 @@ static BOOL MimeLogEnabled = NO; MimeLogEnabled = [self isMIMELogEnabled]; } -- (id)parseValue:(NSString *)_data ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { unsigned len = [_data length]; - unichar src[len+1]; + unichar src[len + 1]; unsigned cnt; BOOL didModify; NSString *str; @@ -49,7 +49,7 @@ static BOOL MimeLogEnabled = NO; [_data getCharacters:src]; - // strip leading spaces + /* strip leading spaces */ if (StripLeadingSpaces) { while (isRfc822_LWSP(src[cnt]) && (len > 0)) { cnt++; @@ -57,7 +57,7 @@ static BOOL MimeLogEnabled = NO; didModify = YES; } } - // strip trailing spaces + /* strip trailing spaces */ while (len > 0) { if (isRfc822_LWSP(src[len - 1])) { len--; @@ -74,10 +74,9 @@ static BOOL MimeLogEnabled = NO; } str = nil; - if (didModify) - str = [[[NSString alloc] initWithCharacters:src+cnt length:len] autorelease]; - else - str = _data; + str = (didModify) + ? [NSString stringWithCharacters:(src + cnt) length:len] + : _data; return [[[NGMimeContentDispositionHeaderField alloc] initWithString:str] autorelease]; diff --git a/sope-mime/NGMime/NGMimeContentLengthHeaderFieldParser.m b/sope-mime/NGMime/NGMimeContentLengthHeaderFieldParser.m index 05fc052a..e6a0c039 100644 --- a/sope-mime/NGMime/NGMimeContentLengthHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeContentLengthHeaderFieldParser.m @@ -30,7 +30,7 @@ return 2; } -- (id)parseValue:(NSString *)_data ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { const char *buf, *ptr; _data = [self removeCommentsFromValue:_data]; diff --git a/sope-mime/NGMime/NGMimeContentTypeHeaderFieldGenerator.m b/sope-mime/NGMime/NGMimeContentTypeHeaderFieldGenerator.m index 5fba916f..390fcead 100644 --- a/sope-mime/NGMime/NGMimeContentTypeHeaderFieldGenerator.m +++ b/sope-mime/NGMime/NGMimeContentTypeHeaderFieldGenerator.m @@ -59,8 +59,8 @@ tmp = [type type]; NSAssert(tmp, @"type should not be nil"); len = [tmp length]; - ctmp = malloc(len + 1); - [tmp getCString:ctmp]; ctmp[len] = '\0'; + ctmp = malloc(len + 4); + [tmp getCString:(char *)ctmp]; ctmp[len] = '\0'; [data appendBytes:ctmp length:len]; free(ctmp); @@ -69,8 +69,8 @@ tmp = [type subType]; if (tmp != nil) { len = [tmp length]; - ctmp = malloc(len + 1); - [tmp getCString:ctmp]; ctmp[len] = '\0'; + ctmp = malloc(len + 4); + [tmp getCString:(char *)ctmp]; ctmp[len] = '\0'; [data appendBytes:ctmp length:len]; free(ctmp); } @@ -93,7 +93,7 @@ len = [name cStringLength]; ctmp = malloc(len + 1); - [name getCString:ctmp]; ctmp[len] = '\0'; + [name getCString:(char *)ctmp]; ctmp[len] = '\0'; [data appendBytes:ctmp length:len]; free(ctmp); @@ -108,8 +108,8 @@ BOOL doEnc; len = [value cStringLength]; - ctmp = malloc(len + 1); - [value getCString:ctmp]; ctmp[len] = '\0'; + ctmp = malloc(len + 4); + [value getCString:(char *)ctmp]; ctmp[len] = '\0'; cnt = 0; doEnc = NO; while (cnt < len) { diff --git a/sope-mime/NGMime/NGMimeContentTypeHeaderFieldParser.m b/sope-mime/NGMime/NGMimeContentTypeHeaderFieldParser.m index dff87f1a..9c95ab52 100644 --- a/sope-mime/NGMime/NGMimeContentTypeHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeContentTypeHeaderFieldParser.m @@ -37,7 +37,7 @@ static BOOL MimeLogEnabled = NO; MimeLogEnabled = [self isMIMELogEnabled]; } -- (id)parseValue:(NSString *)_data ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { NSString *typeString; unsigned len; diff --git a/sope-mime/NGMime/NGMimeHeaderFieldParser.m b/sope-mime/NGMime/NGMimeHeaderFieldParser.m index fb333e1a..a4140a0c 100644 --- a/sope-mime/NGMime/NGMimeHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeHeaderFieldParser.m @@ -130,7 +130,7 @@ static int StripLeadingSpaces = -1; return _value; } -- (id)parseValue:(NSString *)_data ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { // abstract NSLog(@"ERROR(%s): subclass should override this method: %@", __PRETTY_FUNCTION__, self); diff --git a/sope-mime/NGMime/NGMimeMultipartBodyGenerator.m b/sope-mime/NGMime/NGMimeMultipartBodyGenerator.m index 3481ba8c..e147a843 100644 --- a/sope-mime/NGMime/NGMimeMultipartBodyGenerator.m +++ b/sope-mime/NGMime/NGMimeMultipartBodyGenerator.m @@ -75,7 +75,7 @@ static inline BOOL _isBoundaryInArray(NGMimeMultipartBodyGenerator *self, BOOL wasFound; // TODO: do we need to treat the boundary as a CString? - boundary = [_boundary cString]; + boundary = (const unsigned char *)[_boundary cString]; length = [_boundary length]; enumerator = [_data objectEnumerator]; data = nil; @@ -105,7 +105,7 @@ static inline BOOL _isBoundaryInArray(NGMimeMultipartBodyGenerator *self, if (bytes[cnt] == '\n') {// LF*- if (bytes[cnt + 1] == '-') { // LF-- - if (strncmp(boundary, bytes + cnt + 3, length) == 0) { + if (strncmp((char *)boundary, (char *)(bytes+cnt+3), length) == 0) { wasFound = YES; break; } @@ -113,13 +113,13 @@ static inline BOOL _isBoundaryInArray(NGMimeMultipartBodyGenerator *self, } else if (bytes[cnt] == '\r') { //CR*- if (bytes[cnt + 1] == '-') { //CR-- - if (strncmp(boundary, bytes + cnt + 3, length) == 0) { + if (strncmp((char *)boundary, (char *)(bytes+cnt+3), length) == 0) { wasFound = YES; break; } } else if ((bytes[cnt + 1] == '\n') && (bytes[cnt + 3] == '-')) { - if (strncmp(boundary, bytes + cnt + 4, length) == 0) { // CRLF-- + if (strncmp((char*)boundary, (char *)(bytes+cnt+4), length)==0) { // CRLF-- wasFound = YES; break; } diff --git a/sope-mime/NGMime/NGMimePartGenerator.m b/sope-mime/NGMime/NGMimePartGenerator.m index bd3015e4..ed61eef4 100644 --- a/sope-mime/NGMime/NGMimePartGenerator.m +++ b/sope-mime/NGMime/NGMimePartGenerator.m @@ -155,7 +155,7 @@ static BOOL debugOn = NO; BOOL isMultiValue, isFirst; /* get field name and strip leading spaces */ - fcname = [_field cString]; + fcname = (const unsigned char *)[_field cString]; for (len = [_field cStringLength]; len > 0; fcname++, len--) { if (*fcname != ' ') break; diff --git a/sope-mime/NGMime/NGMimePartParser.m b/sope-mime/NGMime/NGMimePartParser.m index 5240e0e8..82a60254 100644 --- a/sope-mime/NGMime/NGMimePartParser.m +++ b/sope-mime/NGMime/NGMimePartParser.m @@ -672,10 +672,12 @@ static NSString *fieldNameForCString(id self, char *_cstring, int _len) { if (len > 0) { // len==0 means the value was a string of LWSP [self->contentTransferEncoding release]; self->contentTransferEncoding = - [[StringClass alloc] initWithCString:cstr length:len]; + [[StringClass alloc] initWithCString:(char *)cstr length:len]; } - else - ASSIGN(self->contentTransferEncoding, (id)nil); + else { + [self->contentTransferEncoding release]; + self->contentTransferEncoding = nil; + } } /* take a look on content-length headers, since the parser @@ -702,7 +704,7 @@ static NSString *fieldNameForCString(id self, char *_cstring, int _len) { cstr++; } buf[i] = '\0'; // stop string after last digit (ignore the rest) - self->contentLength = atoi(buf); + self->contentLength = atoi((char *)buf); } else { /* header value are only spaces */ diff --git a/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m b/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m index 2029b567..2ddab9ee 100644 --- a/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeRFC822DateHeaderFieldParser.m @@ -152,9 +152,9 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { (value='Tue, 13 Jul 2004 21:39:28 +0530') TODO: this is because libFoundation doesn't accept 'GMT+0530' as input. */ - unsigned char *p = s; - NSTimeZone *tz; - NSString *ts; + char *p = (char *)s; + NSTimeZone *tz; + NSString *ts; if (len == 0) return nil; @@ -214,7 +214,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { } /* special case for GMT+0530 */ - if (strncmp(s, "+0530", 5) == 0) + if (strncmp((char *)s, "+0530", 5) == 0) return gmt0530; } else if (len == 7) { @@ -228,7 +228,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { if (isdigit(p[1]) && isdigit(p[2]) && (p[3] == '-'||p[3] == '+')) { unsigned char tmp[8]; - strncpy(tmp, p, 3); + strncpy((char *)tmp, p, 3); tmp[3] = '0'; tmp[4] = '0'; tmp[5] = '\0'; @@ -251,23 +251,23 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { } } else if (len == 3) { - if (strcasecmp(s, "GMT") == 0) return gmt; - if (strcasecmp(s, "MET") == 0) return met; + if (strcasecmp((char *)s, "GMT") == 0) return gmt; + if (strcasecmp((char *)s, "MET") == 0) return met; } if (isalpha(*s)) { - ts = [[NSString alloc] initWithCString:s length:len]; + ts = [[NSString alloc] initWithCString:(char *)s length:len]; } else { char buf[len + 5]; buf[0] = 'G'; buf[1] = 'M'; buf[2] = 'T'; if (*s == '+' || *s == '-') { - strcpy(&(buf[3]), s); + strcpy(&(buf[3]), (char *)s); } else { buf[3] = '+'; - strcpy(&(buf[4]), s); + strcpy(&(buf[4]), (char *)s); } ts = [[NSString alloc] initWithCString:buf]; } @@ -279,7 +279,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { return tz; } -- (id)parseValue:(NSString *)_data ofHeaderField:(id)_field { +- (id)parseValue:(id)_data ofHeaderField:(NSString *)_field { // TODO: use UNICODE NSCalendarDate *date = nil; unsigned char buf[256]; @@ -297,7 +297,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { length = 254; } - [_data getCString:buf maxLength:length]; + [_data getCString:(char *)buf maxLength:length]; buf[length] = '\0'; /* remove leading chars (skip to first digit, the day of the month) */ @@ -329,7 +329,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { ; if (*pe == 0) goto failed; *pe = '\0'; - dayOfMonth = atoi(bytes); + dayOfMonth = atoi((char *)bytes); bytes = pe + 1; /* parse month-abbrev (should be English, could be other langs) */ @@ -358,7 +358,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { ; if (*pe == 0) goto failed; *pe = '\0'; - year = atoi(bytes); + year = atoi((char *)bytes); bytes = pe + 1; if (year >= 70 && year < 135) // Y2K year += 1900; @@ -383,7 +383,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { ; flag = (*pe == 0); *pe = '\0'; - hour = bytes != pe ? atoi(bytes) : 0; + hour = bytes != pe ? atoi((char *)bytes) : 0; if (flag) goto finished; // this is: '12\0' bytes = pe + 1; @@ -397,7 +397,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { ; flag = (*pe == 0); *pe = '\0'; - minute = bytes != pe ? atoi(bytes) : 0; + minute = bytes != pe ? atoi((char *)bytes) : 0; if (flag) goto finished; // this is: '12:23\0' bytes = pe + 1; @@ -417,7 +417,7 @@ static NSTimeZone *parseTimeZone(unsigned char *s, unsigned int len) { ; flag = (*pe == 0); *pe = '\0'; - second = bytes != pe ? atoi(bytes) : 0; + second = bytes != pe ? atoi((char *)bytes) : 0; if (flag) goto finished; // this is: '12:23:12\0' bytes = pe + 1; } diff --git a/sope-mime/NGMime/NGMimeStringHeaderFieldParser.m b/sope-mime/NGMime/NGMimeStringHeaderFieldParser.m index 60807c14..ee23c464 100644 --- a/sope-mime/NGMime/NGMimeStringHeaderFieldParser.m +++ b/sope-mime/NGMime/NGMimeStringHeaderFieldParser.m @@ -47,7 +47,7 @@ static BOOL StripLeadingSpaces = NO; /* operation */ -- (id)parseValue:(NSString *)_value ofHeaderField:(NSString *)_field { +- (id)parseValue:(id)_value ofHeaderField:(NSString *)_field { // TODO: fixup unsigned len = [_value length]; unsigned cnt; diff --git a/sope-mime/NGMime/NGMimeType.m b/sope-mime/NGMime/NGMimeType.m index d3e931ff..d941dd62 100644 --- a/sope-mime/NGMime/NGMimeType.m +++ b/sope-mime/NGMime/NGMimeType.m @@ -644,12 +644,12 @@ static BOOL _parseMimeType(id self, NSString *_str, NSString **type, if (len == 0) return NO; // no type was read { - unsigned char buf[len + 1]; + unsigned char buf[len + 3]; register unsigned i; buf[len] = '\0'; for (i = 0; i < len; i++) buf[i] = tolower(tmp[i]); - *type = _stringForType(buf, len); + *type = _stringForType((char *)buf, len); } if (*cstr == '/') { // subtype name @@ -671,7 +671,7 @@ static BOOL _parseMimeType(id self, NSString *_str, NSString **type, buf[len] = '\0'; for (i = 0; i < len; i++) buf[i] = tolower(tmp[i]); - *subType = _stringForSubType(buf, len); + *subType = _stringForSubType((char *)buf, len); } } else { diff --git a/sope-mime/NGMime/NGMimeUtilities.m b/sope-mime/NGMime/NGMimeUtilities.m index 9c772ce9..376398c1 100644 --- a/sope-mime/NGMime/NGMimeUtilities.m +++ b/sope-mime/NGMime/NGMimeUtilities.m @@ -116,7 +116,7 @@ NSDictionary *parseParameters(id self, NSString *_str, unichar *cstr) { buf[len] = '\0'; for (i = 0; i < len; i++) buf[i] = tolower(tmp[i]); - attrName = _stringForParameterName(buf, len); + attrName = _stringForParameterName((char *)buf, len); } // skip spaces while ((*cstr != '\0') && (isRfc822_LWSP(*cstr))) { diff --git a/sope-mime/Version b/sope-mime/Version index 6f8c65aa..02b9ee5d 100644 --- a/sope-mime/Version +++ b/sope-mime/Version @@ -2,7 +2,7 @@ MAJOR_VERSION:=4 MINOR_VERSION:=5 -SUBMINOR_VERSION:=219 +SUBMINOR_VERSION:=220 # v4.5.214 requires libNGExtensions v4.5.146 # v4.2.149 requires libNGStreams v4.2.34