Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
U
userhosts
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
userhosts
Commits
dc7a4a5c
Commit
dc7a4a5c
authored
Aug 28, 2014
by
Vincent Pelletier
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Style: evaluate false expressions to boolean, just as true expressions.
parent
43ec3fd9
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
4 deletions
+4
-4
userhosts.c
userhosts.c
+4
-4
No files found.
userhosts.c
View file @
dc7a4a5c
...
...
@@ -48,7 +48,7 @@ static inline void *dlsym_or_abort(const char *name) {
void
*
symbol
;
dlerror
();
/* Clear any previous error */
symbol
=
dlsym
(
RTLD_NEXT
,
name
);
if
(
NULL
==
symbol
&&
(
error
=
dlerror
()))
{
if
(
!
symbol
&&
(
error
=
dlerror
()))
{
fprintf
(
stderr
,
"Error loading '%s': %s
\n
"
,
name
,
error
);
abort
();
}
...
...
@@ -59,13 +59,13 @@ static void __attribute__ ((constructor)) init(void) {
original_open
=
dlsym_or_abort
(
"open"
);
original_fopen
=
dlsym_or_abort
(
"fopen"
);
replacement_hosts
=
getenv
(
"HOSTS"
);
if
(
replacement_hosts
==
NULL
)
if
(
!
replacement_hosts
)
/* XXX: warn ? fallback on $HOME/???/hosts ? */
replacement_hosts
=
ORIGINAL_HOSTS_PATH
;
}
int
open
(
const
char
*
__file
,
int
__oflag
,
...)
{
if
(
strcmp
(
__file
,
ORIGINAL_HOSTS_PATH
)
==
0
)
if
(
!
strcmp
(
__file
,
ORIGINAL_HOSTS_PATH
)
)
__file
=
replacement_hosts
;
if
(
__oflag
&
(
O_CREAT
|
PURE_O_TMPFILE
))
{
va_list
ap
;
...
...
@@ -80,7 +80,7 @@ int open(const char *__file, int __oflag, ...) {
}
FILE
*
fopen
(
const
char
*
path
,
const
char
*
mode
)
{
if
(
strcmp
(
path
,
ORIGINAL_HOSTS_PATH
)
==
0
)
if
(
!
strcmp
(
path
,
ORIGINAL_HOSTS_PATH
)
)
path
=
replacement_hosts
;
return
(
*
original_fopen
)(
path
,
mode
);
}
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