Overview
Comment: | Rename all remaining enums |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | new-naming-convention |
Files: | files | file ages | folders |
SHA3-256: |
e97b03815fd14425274557860810b4e6 |
User & Date: | js on 2021-04-19 22:20:49 |
Other Links: | branch diff | manifest | tags |
Context
2021-04-19
| ||
23:53 | Fix compilation on Windows check-in: a1ca5fe0fa user: js tags: new-naming-convention | |
22:20 | Rename all remaining enums check-in: e97b03815f user: js tags: new-naming-convention | |
21:54 | Rename a few more constants check-in: 458420998c user: js tags: new-naming-convention | |
Changes
Modified src/OFHTTPCookie.m from [6c798836e9] to [d82c9df2c7].
︙ | ︙ | |||
67 68 69 70 71 72 73 | OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *string = [headerFields objectForKey: @"Set-Cookie"]; OFString *domain = URL.host; const OFUnichar *characters = string.characters; size_t length = string.length, last = 0; enum { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 | OFMutableArray OF_GENERIC(OFHTTPCookie *) *ret = [OFMutableArray array]; void *pool = objc_autoreleasePoolPush(); OFString *string = [headerFields objectForKey: @"Set-Cookie"]; OFString *domain = URL.host; const OFUnichar *characters = string.characters; size_t length = string.length, last = 0; enum { StatePreName, StateName, StateExpectValue, StateValue, StateQuotedValue, StatePostQuotedValue, StatePreAttrName, StateAttrName, StateAttrValue } state = StatePreName; OFString *name = nil, *value = nil; for (size_t i = 0; i < length; i++) { switch (state) { case StatePreName: if (characters[i] != ' ') { state = StateName; last = i; i--; } break; case StateName: if (characters[i] == '=') { name = [string substringWithRange: OFRangeMake(last, i - last)]; state = StateExpectValue; } break; case StateExpectValue: if (characters[i] == '"') { state = StateQuotedValue; last = i + 1; } else { state = StateValue; last = i; } i--; break; case StateValue: if (characters[i] == ';' || characters[i] == ',') { value = [string substringWithRange: OFRangeMake(last, i - last)]; [ret addObject: [OFHTTPCookie cookieWithName: name value: value domain: domain]]; state = (characters[i] == ';' ? StatePreAttrName : StatePreName); } break; case StateQuotedValue: if (characters[i] == '"') { value = [string substringWithRange: OFRangeMake(last, i - last)]; [ret addObject: [OFHTTPCookie cookieWithName: name value: value domain: domain]]; state = StatePostQuotedValue; } break; case StatePostQuotedValue: if (characters[i] == ';') state = StatePreAttrName; else if (characters[i] == ',') state = StatePreName; else @throw [OFInvalidFormatException exception]; break; case StatePreAttrName: if (characters[i] != ' ') { state = StateAttrName; last = i; i--; } break; case StateAttrName: if (characters[i] == '=') { name = [string substringWithRange: OFRangeMake(last, i - last)]; state = StateAttrValue; last = i + 1; } else if (characters[i] == ';' || characters[i] == ',') { name = [string substringWithRange: OFRangeMake(last, i - last)]; handleAttribute(ret.lastObject, name, nil); state = (characters[i] == ';' ? StatePreAttrName : StatePreName); } break; case StateAttrValue: if (characters[i] == ';' || characters[i] == ',') { value = [string substringWithRange: OFRangeMake(last, i - last)]; /* * Expires often contains a comma, even though * the comma is used as a separator for |
︙ | ︙ | |||
194 195 196 197 198 199 200 | [value isEqual: @"Sat"] || [value isEqual: @"Sun"])) break; handleAttribute(ret.lastObject, name, value); state = (characters[i] == ';' | | | | | | | | | | | | 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 | [value isEqual: @"Sat"] || [value isEqual: @"Sun"])) break; handleAttribute(ret.lastObject, name, value); state = (characters[i] == ';' ? StatePreAttrName : StatePreName); } break; } } switch (state) { case StatePreName: case StatePostQuotedValue: case StatePreAttrName: break; case StateName: case StateQuotedValue: @throw [OFInvalidFormatException exception]; break; case StateValue: value = [string substringWithRange: OFRangeMake(last, length - last)]; [ret addObject: [OFHTTPCookie cookieWithName: name value: value domain: domain]]; break; /* We end up here if the cookie is just foo= */ case StateExpectValue: [ret addObject: [OFHTTPCookie cookieWithName: name value: @"" domain: domain]]; break; case StateAttrName: if (last != length) { name = [string substringWithRange: OFRangeMake(last, length - last)]; handleAttribute(ret.lastObject, name, nil); } break; case StateAttrValue: value = [string substringWithRange: OFRangeMake(last, length - last)]; handleAttribute(ret.lastObject, name, value); break; } |
︙ | ︙ |
Modified src/OFHTTPResponse.m from [a079a8cd2f] to [85cc9e3ded].
︙ | ︙ | |||
118 119 120 121 122 123 124 | static OFStringEncoding encodingForContentType(OFString *contentType) { const char *UTF8String = contentType.UTF8String; size_t last, length = contentType.UTF8StringLength; enum { | | | | | | | | | | | | | | | | | | | | | | | | | | 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | static OFStringEncoding encodingForContentType(OFString *contentType) { const char *UTF8String = contentType.UTF8String; size_t last, length = contentType.UTF8StringLength; enum { StateType, StateBeforeParamName, StateParamName, StateParamValueOrQuote, StateParamValue, StateParamQuotedValue, StateAfterParamValue } state = StateType; OFString *name = nil, *value = nil, *charset = nil; OFStringEncoding ret; last = 0; for (size_t i = 0; i < length; i++) { switch (state) { case StateType: if (UTF8String[i] == ';') { state = StateBeforeParamName; last = i + 1; } break; case StateBeforeParamName: if (UTF8String[i] == ' ') last = i + 1; else { state = StateParamName; i--; } break; case StateParamName: if (UTF8String[i] == '=') { name = [OFString stringWithUTF8String: UTF8String + last length: i - last]; state = StateParamValueOrQuote; last = i + 1; } break; case StateParamValueOrQuote: if (UTF8String[i] == '"') { state = StateParamQuotedValue; last = i + 1; } else { state = StateParamValue; i--; } break; case StateParamValue: if (UTF8String[i] == ';') { value = [OFString stringWithUTF8String: UTF8String + last length: i - last]; value = value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; state = StateBeforeParamName; last = i + 1; } break; case StateParamQuotedValue: if (UTF8String[i] == '"') { value = [OFString stringWithUTF8String: UTF8String + last length: i - last]; if ([name isEqual: @"charset"]) charset = value; state = StateAfterParamValue; } break; case StateAfterParamValue: if (UTF8String[i] == ';') { state = StateBeforeParamName; last = i + 1; } else if (UTF8String[i] != ' ') return OFStringEncodingAutodetect; break; } } if (state == StateParamValue) { value = [OFString stringWithUTF8String: UTF8String + last length: length - last]; value = value.stringByDeletingTrailingWhitespaces; if ([name isEqual: @"charset"]) charset = value; } |
︙ | ︙ |
Modified src/OFHTTPServer.m from [77e13e0b81] to [ab2a6a96d7].
︙ | ︙ | |||
72 73 74 75 76 77 78 | @interface OFHTTPServerConnection: OFObject <OFTCPSocketDelegate> { @public OFStreamSocket *_socket; OFHTTPServer *_server; OFTimer *_timer; enum { | | | | | 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 | @interface OFHTTPServerConnection: OFObject <OFTCPSocketDelegate> { @public OFStreamSocket *_socket; OFHTTPServer *_server; OFTimer *_timer; enum { StateAwaitingProlog, StateParsingHeaders, StateSendResponse } _state; uint8_t _HTTPMinorVersion; OFHTTPRequestMethod _method; OFString *_host, *_path; uint16_t _port; OFMutableDictionary *_headers; size_t _contentLength; |
︙ | ︙ | |||
292 293 294 295 296 297 298 | _server = [server retain]; _timer = [[OFTimer scheduledTimerWithTimeInterval: 10 target: _socket selector: @selector( cancelAsyncRequests) repeats: false] retain]; | | | 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 | _server = [server retain]; _timer = [[OFTimer scheduledTimerWithTimeInterval: 10 target: _socket selector: @selector( cancelAsyncRequests) repeats: false] retain]; _state = StateAwaitingProlog; } @catch (id e) { [self release]; @throw e; } return self; } |
︙ | ︙ | |||
326 327 328 329 330 331 332 | exception: (id)exception { if (line == nil || exception != nil) return false; @try { switch (_state) { | | | | 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 | exception: (id)exception { if (line == nil || exception != nil) return false; @try { switch (_state) { case StateAwaitingProlog: return [self parseProlog: line]; case StateParsingHeaders: return [self parseHeaders: line]; default: return false; } } @catch (OFWriteFailedException *e) { return false; } |
︙ | ︙ | |||
391 392 393 394 395 396 397 | [path makeImmutable]; if (![path hasPrefix: @"/"]) return [self sendErrorAndClose: 400]; _headers = [[OFMutableDictionary alloc] init]; _path = [path copy]; | | | 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | [path makeImmutable]; if (![path hasPrefix: @"/"]) return [self sendErrorAndClose: 400]; _headers = [[OFMutableDictionary alloc] init]; _path = [path copy]; _state = StateParsingHeaders; return true; } - (bool)parseHeaders: (OFString *)line { OFString *key, *value, *old; |
︙ | ︙ | |||
433 434 435 436 437 438 439 | contentLength: contentLength]; [_timer invalidate]; [_timer release]; _timer = nil; } | | | 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 | contentLength: contentLength]; [_timer invalidate]; [_timer release]; _timer = nil; } _state = StateSendResponse; [self createResponse]; return false; } pos = [line rangeOfString: @":"].location; if (pos == OFNotFound) |
︙ | ︙ |
Modified src/OFKernelEventObserver.m from [c8344a220c] to [bc5e41d427].
︙ | ︙ | |||
47 48 49 50 51 52 53 | #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> #endif | < < < < < < < < | 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | #import "OFInvalidArgumentException.h" #import "OFOutOfRangeException.h" #ifdef OF_AMIGAOS # include <proto/exec.h> #endif @implementation OFKernelEventObserver @synthesize delegate = _delegate; #ifdef OF_AMIGAOS @synthesize execSignalMask = _execSignalMask; #endif + (void)initialize |
︙ | ︙ |
Modified src/OFNumber.m from [3b421cd558] to [4fabc7778d].
︙ | ︙ | |||
39 40 41 42 43 44 45 | @interface OFNumberPlaceholder: OFNumber @end @interface OFNumberSingleton: OFNumber @end #ifdef OF_OBJFW_RUNTIME | | | | | | | | | | | | | | | 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 | @interface OFNumberPlaceholder: OFNumber @end @interface OFNumberSingleton: OFNumber @end #ifdef OF_OBJFW_RUNTIME enum Tag { TagChar, TagShort, TagInt, TagLong, TagLongLong, TagUnsignedChar, TagUnsignedShort, TagUnsignedInt, TagUnsignedLong, TagUnsignedLongLong, }; static const uint_fast8_t tagBits = 4; static const uintptr_t tagMask = 0xF; @interface OFTaggedPointerNumber: OFNumberSingleton @end #endif static struct { Class isa; |
︙ | ︙ | |||
168 169 170 171 172 173 174 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME | | | | | | | | | | | | | | | | | | | | | | | 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 | - (instancetype)initWithChar: (signed char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, charZeroNumberInit); return (id)charZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned char)value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned char)value << tagBits) | TagChar); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithChar: value]; } - (instancetype)initWithShort: (short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, shortZeroNumberInit); return (id)shortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned short)value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned short)value << tagBits) | TagShort); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithShort: value]; } - (instancetype)initWithInt: (int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, intZeroNumberInit); return (id)intZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned int)value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned int)value << tagBits) | TagInt); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithInt: value]; } - (instancetype)initWithLong: (long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longZeroNumberInit); return (id)longZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long)value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long)value << tagBits) | TagLong); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithLong: value]; } - (instancetype)initWithLongLong: (long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, longLongZeroNumberInit); return (id)longLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if ((unsigned long long)value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)(unsigned long long)value << tagBits) | TagLongLong); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithLongLong: value]; } - (instancetype)initWithUnsignedChar: (unsigned char)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedCharZeroNumberInit); return (id)unsignedCharZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << tagBits) | TagUnsignedChar); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithUnsignedChar: value]; } - (instancetype)initWithUnsignedShort: (unsigned short)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedShortZeroNumberInit); return (id)unsignedShortZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << tagBits) | TagUnsignedShort); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithUnsignedShort: value]; } - (instancetype)initWithUnsignedInt: (unsigned int)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedIntZeroNumberInit); return (id)unsignedIntZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << tagBits) | TagUnsignedInt); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithUnsignedInt: value]; } - (instancetype)initWithUnsignedLong: (unsigned long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongZeroNumberInit); return (id)unsignedLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << tagBits) | TagUnsignedLong); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithUnsignedLong: value]; } - (instancetype)initWithUnsignedLongLong: (unsigned long long)value { if (value == 0) { static OFOnceControl onceControl = OFOnceControlInitValue; OFOnce(&onceControl, unsignedLongLongZeroNumberInit); return (id)unsignedLongLongZeroNumber; #ifdef OF_OBJFW_RUNTIME } else if (value <= (UINTPTR_MAX >> tagBits)) { id ret = objc_createTaggedPointer(numberTag, ((uintptr_t)value << tagBits) | TagUnsignedLongLong); if (ret != nil) return ret; #endif } return (id)[[OFNumber of_alloc] initWithUnsignedLongLong: value]; |
︙ | ︙ | |||
410 411 412 413 414 415 416 | #ifdef OF_OBJFW_RUNTIME @implementation OFTaggedPointerNumber - (const char *)objCType { uintptr_t value = object_getTaggedPointerValue(self); | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 | #ifdef OF_OBJFW_RUNTIME @implementation OFTaggedPointerNumber - (const char *)objCType { uintptr_t value = object_getTaggedPointerValue(self); switch (value & tagMask) { case TagChar: return @encode(signed char); case TagShort: return @encode(short); case TagInt: return @encode(int); case TagLong: return @encode(long); case TagLongLong: return @encode(long long); case TagUnsignedChar: return @encode(unsigned char); case TagUnsignedShort: return @encode(unsigned short); case TagUnsignedInt: return @encode(unsigned int); case TagUnsignedLong: return @encode(unsigned long); case TagUnsignedLongLong: return @encode(unsigned long long); default: @throw [OFInvalidArgumentException exception]; } } # define RETURN_VALUE \ uintptr_t value = object_getTaggedPointerValue(self); \ \ switch (value & tagMask) { \ case TagChar: \ return (signed char)(unsigned char)(value >> tagBits); \ case TagShort: \ return (short)(unsigned short)(value >> tagBits); \ case TagInt: \ return (int)(unsigned int)(value >> tagBits); \ case TagLong: \ return (long)(unsigned long)(value >> tagBits); \ case TagLongLong: \ return (long long)(unsigned long long)(value >> tagBits); \ case TagUnsignedChar: \ return (unsigned char)(value >> tagBits); \ case TagUnsignedShort: \ return (unsigned short)(value >> tagBits); \ case TagUnsignedInt: \ return (unsigned int)(value >> tagBits); \ case TagUnsignedLong: \ return (unsigned long)(value >> tagBits); \ case TagUnsignedLongLong: \ return (unsigned long long)(value >> tagBits); \ default: \ @throw [OFInvalidArgumentException exception]; \ } - (long long)longLongValue { RETURN_VALUE } - (unsigned long long)unsignedLongLongValue |
︙ | ︙ |
Modified utils/ofhttp/OFHTTP.m from [fd5b97783f] to [8591ab818f].
︙ | ︙ | |||
128 129 130 131 132 133 134 | static OFString * fileNameFromContentDisposition(OFString *contentDisposition) { void *pool; const char *UTF8String; size_t UTF8StringLength; enum { | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 | static OFString * fileNameFromContentDisposition(OFString *contentDisposition) { void *pool; const char *UTF8String; size_t UTF8StringLength; enum { StateDispositionType, StateDispositionTypeSemicolon, StateDispositionParamNameSkipSpace, StateDispositionParamName, StateDispositionParamValue, StateDispositionParamQuoted, StateDispositionParamUnquoted, StateDispositionExpectSemicolon } state; size_t last; OFString *type = nil, *paramName = nil, *paramValue; OFMutableDictionary *params; OFString *fileName; if (contentDisposition == nil) return nil; pool = objc_autoreleasePoolPush(); UTF8String = contentDisposition.UTF8String; UTF8StringLength = contentDisposition.UTF8StringLength; state = StateDispositionType; params = [OFMutableDictionary dictionary]; last = 0; for (size_t i = 0; i < UTF8StringLength; i++) { switch (state) { case StateDispositionType: if (UTF8String[i] == ';' || UTF8String[i] == ' ') { type = [OFString stringWithUTF8String: UTF8String length: i]; state = (UTF8String[i] == ';' ? StateDispositionParamNameSkipSpace : StateDispositionTypeSemicolon); last = i + 1; } break; case StateDispositionTypeSemicolon: if (UTF8String[i] == ';') { state = StateDispositionParamNameSkipSpace; last = i + 1; } else if (UTF8String[i] != ' ') { objc_autoreleasePoolPop(pool); return nil; } break; case StateDispositionParamNameSkipSpace: if (UTF8String[i] != ' ') { state = StateDispositionParamName; last = i; i--; } break; case StateDispositionParamName: if (UTF8String[i] == '=') { paramName = [OFString stringWithUTF8String: UTF8String + last length: i - last]; state = StateDispositionParamValue; } break; case StateDispositionParamValue: if (UTF8String[i] == '"') { state = StateDispositionParamQuoted; last = i + 1; } else { state = StateDispositionParamUnquoted; last = i; i--; } break; case StateDispositionParamQuoted: if (UTF8String[i] == '"') { paramValue = [OFString stringWithUTF8String: UTF8String + last length: i - last]; [params setObject: paramValue forKey: paramName.lowercaseString]; state = StateDispositionExpectSemicolon; } break; case StateDispositionParamUnquoted: if (UTF8String[i] <= 31 || UTF8String[i] >= 127) return nil; switch (UTF8String[i]) { case ' ': case '"': case '(': case ')': case ',': case '/': case ':': case '<': case '=': case '>': case '?': case '@': case '[': case '\\': case ']': case '{': case '}': return nil; case ';': paramValue = [OFString stringWithUTF8String: UTF8String + last length: i - last]; [params setObject: paramValue forKey: paramName.lowercaseString]; state = StateDispositionParamNameSkipSpace; break; } break; case StateDispositionExpectSemicolon: if (UTF8String[i] == ';') { state = StateDispositionParamNameSkipSpace; last = i + 1; } else if (UTF8String[i] != ' ') { objc_autoreleasePoolPop(pool); return nil; } break; } } if (state == StateDispositionParamUnquoted) { paramValue = [OFString stringWithUTF8String: UTF8String + last length: UTF8StringLength - last]; [params setObject: paramValue forKey: paramName.lowercaseString]; } else if (state != StateDispositionExpectSemicolon) { objc_autoreleasePoolPop(pool); return nil; } if (![type isEqual: @"attachment"] || (fileName = [params objectForKey: @"filename"]) == nil) { objc_autoreleasePoolPop(pool); |
︙ | ︙ |