Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
ae9dfb84
Commit
ae9dfb84
authored
Jun 04, 2021
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Commentary. Make errtxt optional arg.
parent
9eff155d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
39 additions
and
3 deletions
+39
-3
vnum.c
lib/libvarnish/vnum.c
+39
-3
No files found.
lib/libvarnish/vnum.c
View file @
ae9dfb84
...
...
@@ -27,7 +27,8 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* Deal with numbers with data storage suffix scaling
* Deal with numbers.
*
*/
#include "config.h"
...
...
@@ -63,6 +64,11 @@ static const char err_fractional_bytes[] = "Fractional BYTES not allowed";
return (retval); \
} while (0)
/*
* Internal function for parsing an integer with a limited
* number of digits.
*/
static
int64_t
sf_parse_int
(
const
char
**
ipp
,
const
char
**
errtxt
,
int
*
sign
,
int
maxdig
)
{
...
...
@@ -71,7 +77,8 @@ sf_parse_int(const char **ipp, const char **errtxt, int *sign, int maxdig)
AN
(
ipp
);
AN
(
*
ipp
);
*
errtxt
=
NULL
;
if
(
errtxt
!=
NULL
)
*
errtxt
=
NULL
;
*
sign
=
1
;
errno
=
0
;
while
(
vct_isows
(
*
(
*
ipp
)))
...
...
@@ -94,6 +101,14 @@ sf_parse_int(const char **ipp, const char **errtxt, int *sign, int maxdig)
return
(
retval
);
}
/**********************************************************************
* Parse a RFC8941 `sf-integer`.
*
* If `errno` is non-zero the conversion failed.
* If `errtxt` is provided it summarily tells why.
* The input argument points to the first character not consumed.
*/
int64_t
SF_Parse_Integer
(
const
char
**
ipp
,
const
char
**
errtxt
)
{
...
...
@@ -104,6 +119,14 @@ SF_Parse_Integer(const char **ipp, const char **errtxt)
return
(
retval
*
sign
);
}
/**********************************************************************
* Parse either a RFC8941 `sf-integer` or `sf-decimal`.
*
* If `errno` is non-zero the conversion failed.
* If `errtxt` is provided it summarily tells why.
* The input argument points to the first character not consumed.
*/
double
SF_Parse_Number
(
const
char
**
ipp
,
int
strict
,
const
char
**
errtxt
)
{
...
...
@@ -141,6 +164,14 @@ SF_Parse_Number(const char **ipp, int strict, const char **errtxt)
return
(
retval
*
sign
);
}
/**********************************************************************
* Parse a RFC8941 `sf-decimal`.
*
* If `errno` is non-zero the conversion failed.
* If `errtxt` is provided it summarily tells why.
* The input argument points to the first character not consumed.
*/
double
SF_Parse_Decimal
(
const
char
**
ipp
,
int
strict
,
const
char
**
errtxt
)
{
...
...
@@ -154,7 +185,12 @@ SF_Parse_Decimal(const char **ipp, int strict, const char **errtxt)
return
(
retval
);
}
/**********************************************************************/
/**********************************************************************
* Parse a "Varnish number".
*
* Varnish numbers are the union of RFC8941 sf-integer and sf-decimal.
* If `errno` is non-zero the conversion failed and NAN is returned.
*/
double
VNUM
(
const
char
*
p
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment