]>
Commit | Line | Data |
---|---|---|
0f9db2d6 | 1 | /* |
5b74111a | 2 | * Copyright (C) 1996-2018 The Squid Software Foundation and contributors |
0f9db2d6 | 3 | * |
bbc27441 AJ |
4 | * Squid software is distributed under GPLv2+ license and includes |
5 | * contributions from numerous individuals and organizations. | |
6 | * Please see the COPYING and CONTRIBUTORS files for details. | |
0f9db2d6 AJ |
7 | */ |
8 | ||
bbc27441 AJ |
9 | /* DEBUG: section 25 MiME Header Parsing */ |
10 | ||
582c2af2 | 11 | #include "squid.h" |
582c2af2 FC |
12 | #include "Debug.h" |
13 | #include "profiler/Profiler.h" | |
0f9db2d6 | 14 | |
0f9db2d6 | 15 | size_t |
00237269 | 16 | headersEnd(const char *mime, size_t l, bool &containsObsFold) |
0f9db2d6 AJ |
17 | { |
18 | size_t e = 0; | |
19 | int state = 1; | |
00237269 | 20 | containsObsFold = false; |
0f9db2d6 AJ |
21 | |
22 | PROF_start(headersEnd); | |
23 | ||
24 | while (e < l && state < 3) { | |
25 | switch (state) { | |
26 | ||
27 | case 0: | |
28 | ||
29 | if ('\n' == mime[e]) | |
30 | state = 1; | |
31 | ||
32 | break; | |
33 | ||
34 | case 1: | |
35 | if ('\r' == mime[e]) | |
36 | state = 2; | |
37 | else if ('\n' == mime[e]) | |
38 | state = 3; | |
00237269 AJ |
39 | else if (' ' == mime[e] || '\t' == mime[e]) { |
40 | containsObsFold = true; | |
41 | state = 0; | |
42 | } else | |
0f9db2d6 AJ |
43 | state = 0; |
44 | ||
45 | break; | |
46 | ||
47 | case 2: | |
48 | if ('\n' == mime[e]) | |
49 | state = 3; | |
50 | else | |
51 | state = 0; | |
52 | ||
53 | break; | |
54 | ||
55 | default: | |
56 | break; | |
57 | } | |
58 | ||
95dc7ff4 | 59 | ++e; |
0f9db2d6 AJ |
60 | } |
61 | PROF_stop(headersEnd); | |
62 | ||
63 | if (3 == state) | |
64 | return e; | |
65 | ||
66 | return 0; | |
67 | } | |
f53969cc | 68 |