]>
Commit | Line | Data |
---|---|---|
0f9db2d6 | 1 | /* |
ef57eb7b | 2 | * Copyright (C) 1996-2016 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 AJ |
15 | size_t |
16 | headersEnd(const char *mime, size_t l) | |
17 | { | |
18 | size_t e = 0; | |
19 | int state = 1; | |
20 | ||
21 | PROF_start(headersEnd); | |
22 | ||
23 | while (e < l && state < 3) { | |
24 | switch (state) { | |
25 | ||
26 | case 0: | |
27 | ||
28 | if ('\n' == mime[e]) | |
29 | state = 1; | |
30 | ||
31 | break; | |
32 | ||
33 | case 1: | |
34 | if ('\r' == mime[e]) | |
35 | state = 2; | |
36 | else if ('\n' == mime[e]) | |
37 | state = 3; | |
38 | else | |
39 | state = 0; | |
40 | ||
41 | break; | |
42 | ||
43 | case 2: | |
44 | if ('\n' == mime[e]) | |
45 | state = 3; | |
46 | else | |
47 | state = 0; | |
48 | ||
49 | break; | |
50 | ||
51 | default: | |
52 | break; | |
53 | } | |
54 | ||
95dc7ff4 | 55 | ++e; |
0f9db2d6 AJ |
56 | } |
57 | PROF_stop(headersEnd); | |
58 | ||
59 | if (3 == state) | |
60 | return e; | |
61 | ||
62 | return 0; | |
63 | } | |
f53969cc | 64 |