Update German translation
[glib.git] / gio / tests / dbus-launch.c
blobfa830656ea9a51cad5ea9da9cc3acdf3fa7a2443
1 /*
2 * Mock version of dbus-launch, for gdbus-unix-addresses test
4 * Copyright © 2015 Collabora Ltd.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
20 #include <glib.h>
22 #ifndef G_OS_UNIX
23 #error This is a Unix-specific test helper
24 #endif
26 #include <errno.h>
27 #include <string.h>
28 #include <sys/types.h>
29 #include <unistd.h>
31 #define ME "GDBus mock version of dbus-launch"
33 static void
34 write_all (const void *ptr,
35 size_t len)
37 const char *p = ptr;
39 while (len > 0)
41 ssize_t done = write (STDOUT_FILENO, p, len);
43 if (done == 0)
45 g_error ("%s: write: EOF", ME);
47 else if (done < 0)
49 if (errno == EINTR)
50 continue;
52 g_error ("%s: write: %s", ME, g_strerror (errno));
54 else
56 if (len < (size_t) done)
57 g_error ("%s: wrote too many bytes?", ME);
59 len -= done;
60 p += done;
65 int
66 main (int argc,
67 char *argv[])
69 pid_t pid = 0x2323;
70 long window_id = 0x42424242;
71 const char *addr = "hello:this=address-is-from-the,mock=dbus-launch";
73 write_all (addr, strlen (addr) + 1);
74 write_all (&pid, sizeof (pid));
75 write_all (&window_id, sizeof (window_id));
76 return 0;