diff options
author | Andreas Baumann <mail@andreasbaumann.cc> | 2017-05-06 16:36:16 +0200 |
---|---|---|
committer | Sven Nierlein <sven@nierlein.de> | 2018-10-22 16:30:31 +0200 |
commit | a739a5614834178ba88d04972b4f4ba9c560e1df (patch) | |
tree | e9ebee27575d064000e9e210dba2b36c914e8544 /plugins/uriparser/UriIp4Base.c | |
parent | 28a4c7076a3115d30aeb3b3b5e5bde715692e4a7 (diff) | |
download | monitoring-plugins-a739a5614834178ba88d04972b4f4ba9c560e1df.tar.gz |
some rework:
- added old style 'redir' function and options along to a new
libcurl internal 'follow' parameter 'curl'
- moved picohttpparser to it's own subdirectory
- added uriparser to be used instead of the home-grown parser in
'redir'
Diffstat (limited to 'plugins/uriparser/UriIp4Base.c')
-rw-r--r-- | plugins/uriparser/UriIp4Base.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/plugins/uriparser/UriIp4Base.c b/plugins/uriparser/UriIp4Base.c new file mode 100644 index 00000000..5cd298fa --- /dev/null +++ b/plugins/uriparser/UriIp4Base.c | |||
@@ -0,0 +1,96 @@ | |||
1 | /* | ||
2 | * uriparser - RFC 3986 URI parsing library | ||
3 | * | ||
4 | * Copyright (C) 2007, Weijia Song <songweijia@gmail.com> | ||
5 | * Copyright (C) 2007, Sebastian Pipping <webmaster@hartwork.org> | ||
6 | * All rights reserved. | ||
7 | * | ||
8 | * Redistribution and use in source and binary forms, with or without | ||
9 | * modification, are permitted provided that the following conditions | ||
10 | * are met: | ||
11 | * | ||
12 | * * Redistributions of source code must retain the above | ||
13 | * copyright notice, this list of conditions and the following | ||
14 | * disclaimer. | ||
15 | * | ||
16 | * * Redistributions in binary form must reproduce the above | ||
17 | * copyright notice, this list of conditions and the following | ||
18 | * disclaimer in the documentation and/or other materials | ||
19 | * provided with the distribution. | ||
20 | * | ||
21 | * * Neither the name of the <ORGANIZATION> nor the names of its | ||
22 | * contributors may be used to endorse or promote products | ||
23 | * derived from this software without specific prior written | ||
24 | * permission. | ||
25 | * | ||
26 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
27 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
28 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS | ||
29 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE | ||
30 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, | ||
31 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
32 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | ||
33 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | ||
34 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | ||
35 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | ||
36 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | ||
37 | * OF THE POSSIBILITY OF SUCH DAMAGE. | ||
38 | */ | ||
39 | |||
40 | /** | ||
41 | * @file UriIp4Base.c | ||
42 | * Holds code independent of the encoding pass. | ||
43 | */ | ||
44 | |||
45 | #ifndef URI_DOXYGEN | ||
46 | # include "UriIp4Base.h" | ||
47 | #endif | ||
48 | |||
49 | |||
50 | |||
51 | void uriStackToOctet(UriIp4Parser * parser, unsigned char * octet) { | ||
52 | switch (parser->stackCount) { | ||
53 | case 1: | ||
54 | *octet = parser->stackOne; | ||
55 | break; | ||
56 | |||
57 | case 2: | ||
58 | *octet = parser->stackOne * 10 | ||
59 | + parser->stackTwo; | ||
60 | break; | ||
61 | |||
62 | case 3: | ||
63 | *octet = parser->stackOne * 100 | ||
64 | + parser->stackTwo * 10 | ||
65 | + parser->stackThree; | ||
66 | break; | ||
67 | |||
68 | default: | ||
69 | ; | ||
70 | } | ||
71 | parser->stackCount = 0; | ||
72 | } | ||
73 | |||
74 | |||
75 | |||
76 | void uriPushToStack(UriIp4Parser * parser, unsigned char digit) { | ||
77 | switch (parser->stackCount) { | ||
78 | case 0: | ||
79 | parser->stackOne = digit; | ||
80 | parser->stackCount = 1; | ||
81 | break; | ||
82 | |||
83 | case 1: | ||
84 | parser->stackTwo = digit; | ||
85 | parser->stackCount = 2; | ||
86 | break; | ||
87 | |||
88 | case 2: | ||
89 | parser->stackThree = digit; | ||
90 | parser->stackCount = 3; | ||
91 | break; | ||
92 | |||
93 | default: | ||
94 | ; | ||
95 | } | ||
96 | } | ||