[ostree] trivial-httpd: Handle -p - as meaning write-port-to-stdout
- From: Colin Walters <walters src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ostree] trivial-httpd: Handle -p - as meaning write-port-to-stdout
- Date: Fri, 23 Aug 2013 16:42:55 +0000 (UTC)
commit 4f127b2d7db3d28ac5d7a29c8e087be05b2df006
Author: Vivek Dasmohapatra <vivek collabora co uk>
Date: Thu Aug 22 18:28:14 2013 +0100
trivial-httpd: Handle -p - as meaning write-port-to-stdout
This is convenient to use from tests.
src/ostree/ot-builtin-trivial-httpd.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/src/ostree/ot-builtin-trivial-httpd.c b/src/ostree/ot-builtin-trivial-httpd.c
index 610e196..178f20c 100644
--- a/src/ostree/ot-builtin-trivial-httpd.c
+++ b/src/ostree/ot-builtin-trivial-httpd.c
@@ -39,7 +39,7 @@ typedef struct {
static GOptionEntry options[] = {
{ "daemonize", 'd', 0, G_OPTION_ARG_NONE, &opt_daemonize, "Fork into background when ready", NULL },
{ "autoexit", 0, 0, G_OPTION_ARG_NONE, &opt_autoexit, "Automatically exit when directory is deleted", NULL
},
- { "port-file", 'p', 0, G_OPTION_ARG_FILENAME, &opt_port_file, "Write port number to PATH", "PATH" },
+ { "port-file", 'p', 0, G_OPTION_ARG_FILENAME, &opt_port_file, "Write port number to PATH (- for standard
output)", "PATH" },
{ "force-range-requests", 0, 0, G_OPTION_ARG_NONE, &opt_force_ranges, "Force range requests by only
serving half of files", NULL },
{ NULL }
};
@@ -311,7 +311,9 @@ ostree_builtin_trivial_httpd (int argc, char **argv, GFile *repo_path, GCancella
if (opt_port_file)
{
gs_free char *portstr = g_strdup_printf ("%u\n", soup_server_get_port (server));
- if (!g_file_set_contents (opt_port_file, portstr, strlen (portstr), error))
+ if (g_strcmp0 ("-", opt_port_file) == 0)
+ fputs (portstr, stdout); // not g_print - this must go to stdout, not a handler
+ else if (!g_file_set_contents (opt_port_file, portstr, strlen (portstr), error))
goto out;
}
soup_server_run_async (server);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]