From 604fd69ed13329d6b5480f79a772fa6d237a8c48 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Gl=C3=A4=C3=9Fle?= Date: Mon, 6 Jul 2015 18:33:32 +0200 Subject: [PATCH] Add launch functions taking GString inputs --- src/udisksdaemon.c | 92 +++++++++++++++++++++++++++++++++++++++++++++++++----- src/udisksdaemon.h | 22 +++++++++++++ 2 files changed, 107 insertions(+), 7 deletions(-) diff --git a/src/udisksdaemon.c b/src/udisksdaemon.c index 1ba0047..f8c0039 100644 --- a/src/udisksdaemon.c +++ b/src/udisksdaemon.c @@ -648,24 +648,59 @@ udisks_daemon_launch_spawned_job (UDisksDaemon *daemon, { va_list var_args; gchar *command_line; + GString *input_string_as_gstring = NULL; + UDisksBaseJob *job; + + if (input_string != NULL) + input_string_as_gstring = g_string_new (input_string); + + va_start (var_args, command_line_format); + command_line = g_strdup_vprintf (command_line_format, var_args); + va_end (var_args); + + job = udisks_daemon_launch_spawned_job_gstring (daemon, + object, + job_operation, + job_started_by_uid, + cancellable, + run_as_uid, + run_as_euid, + input_string_as_gstring, + "%s", + command_line); + + udisks_string_wipe_and_free(input_string_as_gstring); + return job; +} + +UDisksBaseJob * +udisks_daemon_launch_spawned_job_gstring ( + UDisksDaemon *daemon, + UDisksObject *object, + const gchar *job_operation, + uid_t job_started_by_uid, + GCancellable *cancellable, + uid_t run_as_uid, + uid_t run_as_euid, + GString *input_string, + const gchar *command_line_format, + ...) +{ + va_list var_args; + gchar *command_line; UDisksSpawnedJob *job; UDisksObjectSkeleton *job_object; gchar *job_object_path; - GString *input_string_as_gstring = NULL; g_return_val_if_fail (UDISKS_IS_DAEMON (daemon), NULL); g_return_val_if_fail (cancellable == NULL || G_IS_CANCELLABLE (cancellable), NULL); g_return_val_if_fail (command_line_format != NULL, NULL); - if (input_string != NULL) - input_string_as_gstring = g_string_new (input_string); - va_start (var_args, command_line_format); command_line = g_strdup_vprintf (command_line_format, var_args); va_end (var_args); - job = udisks_spawned_job_new (command_line, input_string_as_gstring, run_as_uid, run_as_euid, daemon, cancellable); + job = udisks_spawned_job_new (command_line, input_string, run_as_uid, run_as_euid, daemon, cancellable); g_free (command_line); - udisks_string_wipe_and_free(input_string_as_gstring); if (object != NULL) udisks_base_job_add_object (UDISKS_BASE_JOB (job), object); @@ -761,6 +796,49 @@ udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon, { va_list var_args; gchar *command_line; + GString *input_string_as_gstring = NULL; + gboolean ret; + + if (input_string != NULL) + input_string_as_gstring = g_string_new (input_string); + + va_start (var_args, command_line_format); + command_line = g_strdup_vprintf (command_line_format, var_args); + va_end (var_args); + + ret = udisks_daemon_launch_spawned_job_gstring_sync (daemon, + object, + job_operation, + job_started_by_uid, + cancellable, + run_as_uid, + run_as_euid, + out_status, + out_message, + input_string_as_gstring, + "%s", + command_line); + + udisks_string_wipe_and_free(input_string_as_gstring); + return ret; +} + +gboolean +udisks_daemon_launch_spawned_job_gstring_sync (UDisksDaemon *daemon, + UDisksObject *object, + const gchar *job_operation, + uid_t job_started_by_uid, + GCancellable *cancellable, + uid_t run_as_uid, + uid_t run_as_euid, + gint *out_status, + gchar **out_message, + GString *input_string, + const gchar *command_line_format, + ...) +{ + va_list var_args; + gchar *command_line; UDisksBaseJob *job; SpawnedJobSyncData data; @@ -778,7 +856,7 @@ udisks_daemon_launch_spawned_job_sync (UDisksDaemon *daemon, va_start (var_args, command_line_format); command_line = g_strdup_vprintf (command_line_format, var_args); va_end (var_args); - job = udisks_daemon_launch_spawned_job (daemon, + job = udisks_daemon_launch_spawned_job_gstring (daemon, object, job_operation, job_started_by_uid, diff --git a/src/udisksdaemon.h b/src/udisksdaemon.h index 6005e91..ad1ff8e 100644 --- a/src/udisksdaemon.h +++ b/src/udisksdaemon.h @@ -100,6 +100,28 @@ gboolean udisks_daemon_launch_spawned_job_sync (UDisksDaemon const gchar *input_string, const gchar *command_line_format, ...) G_GNUC_PRINTF (11, 12); +UDisksBaseJob *udisks_daemon_launch_spawned_job_gstring (UDisksDaemon *daemon, + UDisksObject *object, + const gchar *job_operation, + uid_t job_started_by_uid, + GCancellable *cancellable, + uid_t run_as_uid, + uid_t run_as_euid, + GString *input_string, + const gchar *command_line_format, + ...) G_GNUC_PRINTF (9, 10); +gboolean udisks_daemon_launch_spawned_job_gstring_sync (UDisksDaemon *daemon, + UDisksObject *object, + const gchar *job_operation, + uid_t job_started_by_uid, + GCancellable *cancellable, + uid_t run_as_uid, + uid_t run_as_euid, + gint *out_status, + gchar **out_message, + GString *input_string, + const gchar *command_line_format, + ...) G_GNUC_PRINTF (11, 12); UDisksBaseJob *udisks_daemon_launch_threaded_job (UDisksDaemon *daemon, UDisksObject *object, const gchar *job_operation, -- 2.10.2