/**
* SECTION:gapplicationcommandline
* @title: GApplicationCommandLine
- * @short_description: A class representing a command-line invocation of
- * an application
+ * @short_description: A command-line invocation of an application
* @see_also: #GApplication
*
* #GApplicationCommandLine represents a command-line invocation of
* of this object (ie: the process exits when the last reference is
* dropped).
*
- * <example id="gapplication-example-cmdline"><title>Handling commandline arguments with GApplication</title><programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-cmdline.c"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting></example>
- *
- * <example id="gapplication-example-cmdline2"><title>Complicated commandline handling</title><programlisting><xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-cmdline2.c"><xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback></xi:include></programlisting></example>
+ * <example id="gapplication-example-cmdline"><title>Handling commandline arguments with GApplication</title>
+ * <programlisting>
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-cmdline.c">
+ * <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
+ * </xi:include>
+ * </programlisting>
+ * </example>
+ *
+ * <example id="gapplication-example-cmdline2"><title>Complicated commandline handling</title>
+ * <programlisting>
+ * <xi:include xmlns:xi="http://www.w3.org/2001/XInclude" parse="text" href="../../../../gio/tests/gapplication-example-cmdline2.c">
+ * <xi:fallback>FIXME: MISSING XINCLUDE CONTENT</xi:fallback>
+ * </xi:include>
+ * </programlisting>
+ * </example>
**/
enum
GVariant *platform_data;
GVariant *arguments;
GVariant *cwd;
+
+ const gchar **environ;
gint exit_status;
};
if (!cmdline->priv->cwd)
cmdline->priv->cwd = g_variant_ref (value);
}
+
+ else if (strcmp (key, "environ") == 0)
+ {
+ if (!cmdline->priv->environ)
+ cmdline->priv->environ =
+ g_variant_get_bytestring_array (value, NULL);
+ }
}
static void
}
/**
+ * g_application_command_line_get_environ:
+ * @cmdline: a #GApplicationCommandLine
+ *
+ * Gets the contents of the 'environ' variable of the command line
+ * invocation, as would be returned by g_get_environ(). The strings may
+ * contain non-utf8 data.
+ *
+ * The remote application usually does not send an environment. Use
+ * %G_APPLICATION_SEND_ENVIRONMENT to affect that. Even with this flag
+ * set it is possible that the environment is still not available (due
+ * to invocation messages from other applications).
+ *
+ * The return value should not be modified or freed and is valid for as
+ * long as @cmdline exists.
+ *
+ * Returns: the environment strings, or %NULL if they were not sent
+ *
+ * Since: 2.28
+ **/
+const gchar * const *
+g_application_command_line_get_environ (GApplicationCommandLine *cmdline)
+{
+ return cmdline->priv->environ;
+}
+
+/**
+ * g_application_command_line_getenv:
+ * @cmdline: a #GApplicationCommandLine
+ * @name: the environment variable to get
+ *
+ * Gets the value of a particular environment variable of the command
+ * line invocation, as would be returned by g_getenv(). The strings may
+ * contain non-utf8 data.
+ *
+ * The remote application usually does not send an environment. Use
+ * %G_APPLICATION_SEND_ENVIRONMENT to affect that. Even with this flag
+ * set it is possible that the environment is still not available (due
+ * to invocation messages from other applications).
+ *
+ * The return value should not be modified or freed and is valid for as
+ * long as @cmdline exists.
+ *
+ * Returns: the value of the variable, or %NULL if unset or unsent
+ *
+ * Since: 2.28
+ **/
+const gchar *
+g_application_command_line_getenv (GApplicationCommandLine *cmdline,
+ const gchar *name)
+{
+ gint length = strlen (name);
+ gint i;
+
+ /* TODO: expand on windows */
+ if (cmdline->priv->environ)
+ for (i = 0; cmdline->priv->environ[i]; i++)
+ if (strncmp (cmdline->priv->environ[i], name, length) == 0 &&
+ cmdline->priv->environ[i][length] == '=')
+ return cmdline->priv->environ[i] + length + 1;
+
+ return NULL;
+}
+
+/**
* g_application_command_line_get_is_remote:
* @cmdline: a #GApplicationCommandLine
*