Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
steam-runtime-tools
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
steamrt
steam-runtime-tools
Commits
fa8a6704
Commit
fa8a6704
authored
4 years ago
by
Simon McVittie
Browse files
Options
Downloads
Patches
Plain Diff
wrap, adverb: Share pv_boolean_environment()
Signed-off-by:
Simon McVittie
<
smcv@collabora.com
>
parent
0a71eb0c
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/adverb.c
+1
-19
1 addition, 19 deletions
src/adverb.c
src/utils.c
+18
-0
18 additions, 0 deletions
src/utils.c
src/utils.h
+3
-0
3 additions, 0 deletions
src/utils.h
src/wrap.c
+9
-27
9 additions, 27 deletions
src/wrap.c
with
31 additions
and
46 deletions
src/adverb.c
+
1
−
19
View file @
fa8a6704
...
...
@@ -317,24 +317,6 @@ cli_log_func (const gchar *log_domain,
g_printerr
(
"%s: %s
\n
"
,
(
const
char
*
)
user_data
,
message
);
}
static
gboolean
boolean_environment
(
const
gchar
*
name
,
gboolean
def
)
{
const
gchar
*
value
=
g_getenv
(
name
);
if
(
g_strcmp0
(
value
,
"1"
)
==
0
)
return
TRUE
;
if
(
g_strcmp0
(
value
,
""
)
==
0
||
g_strcmp0
(
value
,
"0"
)
==
0
)
return
FALSE
;
if
(
value
!=
NULL
)
g_warning
(
"Unrecognised value
\"
%s
\"
for $%s"
,
value
,
name
);
return
def
;
}
int
main
(
int
argc
,
char
*
argv
[])
...
...
@@ -370,7 +352,7 @@ main (int argc,
g_option_context_add_main_entries
(
context
,
options
,
NULL
);
opt_verbose
=
boolean_environment
(
"PRESSURE_VESSEL_VERBOSE"
,
FALSE
);
opt_verbose
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_VERBOSE"
,
FALSE
);
if
(
!
g_option_context_parse
(
context
,
&
argc
,
&
argv
,
error
))
{
...
...
This diff is collapsed.
Click to expand it.
src/utils.c
+
18
−
0
View file @
fa8a6704
...
...
@@ -449,6 +449,24 @@ pv_rm_rf (const char *directory)
return
TRUE
;
}
gboolean
pv_boolean_environment
(
const
gchar
*
name
,
gboolean
def
)
{
const
gchar
*
value
=
g_getenv
(
name
);
if
(
g_strcmp0
(
value
,
"1"
)
==
0
)
return
TRUE
;
if
(
g_strcmp0
(
value
,
""
)
==
0
||
g_strcmp0
(
value
,
"0"
)
==
0
)
return
FALSE
;
if
(
value
!=
NULL
)
g_warning
(
"Unrecognised value
\"
%s
\"
for $%s"
,
value
,
name
);
return
def
;
}
/**
* pv_divert_stdout_to_stderr:
* @error: Used to raise an error on failure
...
...
This diff is collapsed.
Click to expand it.
src/utils.h
+
3
−
0
View file @
fa8a6704
...
...
@@ -51,4 +51,7 @@ gboolean pv_cheap_tree_copy (const char *source_root,
gboolean
pv_rm_rf
(
const
char
*
directory
);
gboolean
pv_boolean_environment
(
const
gchar
*
name
,
gboolean
def
);
FILE
*
pv_divert_stdout_to_stderr
(
GError
**
error
);
This diff is collapsed.
Click to expand it.
src/wrap.c
+
9
−
27
View file @
fa8a6704
...
...
@@ -696,24 +696,6 @@ static GOptionEntry options[] =
{
NULL
}
};
static
gboolean
boolean_environment
(
const
gchar
*
name
,
gboolean
def
)
{
const
gchar
*
value
=
g_getenv
(
name
);
if
(
g_strcmp0
(
value
,
"1"
)
==
0
)
return
TRUE
;
if
(
g_strcmp0
(
value
,
""
)
==
0
||
g_strcmp0
(
value
,
"0"
)
==
0
)
return
FALSE
;
if
(
value
!=
NULL
)
g_warning
(
"Unrecognised value
\"
%s
\"
for $%s"
,
value
,
name
);
return
def
;
}
static
Tristate
tristate_environment
(
const
gchar
*
name
)
{
...
...
@@ -789,7 +771,7 @@ main (int argc,
}
/* Set defaults */
opt_batch
=
boolean_environment
(
"PRESSURE_VESSEL_BATCH"
,
FALSE
);
opt_batch
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_BATCH"
,
FALSE
);
opt_freedesktop_app_id
=
g_strdup
(
g_getenv
(
"PRESSURE_VESSEL_FDO_APP_ID"
));
...
...
@@ -801,15 +783,15 @@ main (int argc,
if
(
opt_home
!=
NULL
&&
opt_home
[
0
]
==
'\0'
)
g_clear_pointer
(
&
opt_home
,
g_free
);
opt_remove_game_overlay
=
boolean_environment
(
"PRESSURE_VESSEL_REMOVE_GAME_OVERLAY"
,
FALSE
);
opt_remove_game_overlay
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_REMOVE_GAME_OVERLAY"
,
FALSE
);
opt_share_home
=
tristate_environment
(
"PRESSURE_VESSEL_SHARE_HOME"
);
opt_gc_runtimes
=
boolean_environment
(
"PRESSURE_VESSEL_GC_RUNTIMES"
,
TRUE
);
opt_generate_locales
=
boolean_environment
(
"PRESSURE_VESSEL_GENERATE_LOCALES"
,
TRUE
);
opt_host_graphics
=
boolean_environment
(
"PRESSURE_VESSEL_HOST_GRAPHICS"
,
TRUE
);
opt_share_pid
=
boolean_environment
(
"PRESSURE_VESSEL_SHARE_PID"
,
TRUE
);
opt_verbose
=
boolean_environment
(
"PRESSURE_VESSEL_VERBOSE"
,
FALSE
);
opt_gc_runtimes
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_GC_RUNTIMES"
,
TRUE
);
opt_generate_locales
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_GENERATE_LOCALES"
,
TRUE
);
opt_host_graphics
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_HOST_GRAPHICS"
,
TRUE
);
opt_share_pid
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_SHARE_PID"
,
TRUE
);
opt_verbose
=
pv_
boolean_environment
(
"PRESSURE_VESSEL_VERBOSE"
,
FALSE
);
if
(
!
opt_shell_cb
(
"$PRESSURE_VESSEL_SHELL"
,
g_getenv
(
"PRESSURE_VESSEL_SHELL"
),
NULL
,
error
))
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment