Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnishevent
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
uplex-varnish
varnishevent
Commits
936275c9
Commit
936275c9
authored
Sep 20, 2015
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
strfTIM() gets its temp buffer from the stack, rather than using a VSB
parent
e5cb895e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
20 deletions
+21
-20
strfTIM.c
src/strfTIM.c
+21
-20
No files found.
src/strfTIM.c
View file @
936275c9
...
...
@@ -33,11 +33,11 @@
#include <sys/types.h>
#include <errno.h>
#include <math.h>
#include <stdio.h>
#include "strfTIM.h"
#include "vas.h"
#include "vsb.h"
/*
* cf. vtim.c/VTIM:timespec in libvarnish
...
...
@@ -55,38 +55,39 @@ double2timeval(double t)
size_t
strfTIM
(
char
*
s
,
size_t
max
,
const
char
*
fmt
,
struct
tm
*
tm
,
unsigned
usec
)
{
struct
vsb
*
vsb
=
VSB_new
(
NULL
,
NULL
,
max
,
VSB_FIXEDLEN
);
const
char
*
p
;
size_t
n
;
char
newfmt
[
max
],
*
f
=
newfmt
;
size_t
n
,
len
=
0
;
assert
(
usec
<
1000000
);
for
(
p
=
fmt
;
*
p
;
p
++
)
{
if
(
*
p
!=
'%'
)
{
VSB_putc
(
vsb
,
*
p
);
len
++
;
if
(
len
>
max
)
return
0
;
*
f
++
=
*
p
;
continue
;
}
p
++
;
if
(
*
p
==
'%'
)
{
VSB_cat
(
vsb
,
"%%"
);
continue
;
}
if
(
*
p
!=
'i'
)
{
VSB_putc
(
vsb
,
'%'
);
VSB_putc
(
vsb
,
*
p
);
len
+=
2
;
if
(
len
>
max
)
return
0
;
*
f
++
=
'%'
;
*
f
++
=
*
p
;
continue
;
}
VSB_printf
(
vsb
,
"%06u"
,
usec
);
}
VSB_finish
(
vsb
);
if
(
VSB_error
(
vsb
))
{
VSB_delete
(
vsb
);
return
0
;
len
+=
6
;
if
(
len
>
max
)
return
0
;
sprintf
(
f
,
"%06u"
,
usec
);
f
+=
6
;
}
if
(
len
+
1
>
max
)
return
0
;
*
f
=
'\0'
;
n
=
strftime
(
s
,
max
,
VSB_data
(
vsb
),
tm
);
VSB_delete
(
vsb
);
n
=
strftime
(
s
,
max
,
newfmt
,
tm
);
return
n
;
}
...
...
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