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
ecf13bf2
Commit
ecf13bf2
authored
Jan 02, 2017
by
Dridi Boukelmoune
Committed by
guillaume quintard
Jan 09, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract opening file by name to its own function
parent
0512e0c9
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
9 deletions
+18
-9
vfil.c
lib/libvarnish/vfil.c
+18
-9
No files found.
lib/libvarnish/vfil.c
View file @
ecf13bf2
...
...
@@ -85,21 +85,30 @@ vfil_readfd(int fd, ssize_t *sz)
return
(
f
);
}
static
int
vfil_openfile
(
const
char
*
pfx
,
const
char
*
fn
,
int
flags
,
int
mode
)
{
char
fnb
[
PATH_MAX
+
1
];
if
(
fn
[
0
]
!=
'/'
&&
pfx
!=
NULL
)
{
/* XXX: graceful length check */
bprintf
(
fnb
,
"/%s/%s"
,
pfx
,
fn
);
fn
=
fnb
;
}
if
(
flags
&
O_CREAT
)
return
(
open
(
fn
,
flags
,
mode
));
else
return
(
open
(
fn
,
flags
));
}
char
*
VFIL_readfile
(
const
char
*
pfx
,
const
char
*
fn
,
ssize_t
*
sz
)
{
int
fd
,
err
;
char
*
r
;
char
fnb
[
PATH_MAX
+
1
];
if
(
fn
[
0
]
==
'/'
)
fd
=
open
(
fn
,
O_RDONLY
);
else
if
(
pfx
!=
NULL
)
{
bprintf
(
fnb
,
"/%s/%s"
,
pfx
,
fn
);
/* XXX: graceful length check */
fd
=
open
(
fnb
,
O_RDONLY
);
}
else
fd
=
open
(
fn
,
O_RDONLY
);
fd
=
vfil_openfile
(
pfx
,
fn
,
O_RDONLY
,
0
);
if
(
fd
<
0
)
return
(
NULL
);
r
=
vfil_readfd
(
fd
,
sz
);
...
...
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