diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile.am | 18 | ||||
-rw-r--r-- | tools/Makefile.in | 133 | ||||
-rw-r--r-- | tools/dbus-cleanup-sockets.1 | 43 | ||||
-rw-r--r-- | tools/dbus-launch-win.c | 170 | ||||
-rw-r--r-- | tools/dbus-launch-x11.c | 4 | ||||
-rw-r--r-- | tools/dbus-launch.1 | 183 | ||||
-rw-r--r-- | tools/dbus-launch.c | 14 | ||||
-rw-r--r-- | tools/dbus-launch.h | 1 | ||||
-rw-r--r-- | tools/dbus-monitor.1 | 78 | ||||
-rw-r--r-- | tools/dbus-monitor.c | 27 | ||||
-rw-r--r-- | tools/dbus-print-message.c | 4 | ||||
-rw-r--r-- | tools/dbus-send.1 | 95 | ||||
-rw-r--r-- | tools/dbus-send.c | 18 | ||||
-rw-r--r-- | tools/dbus-uuidgen.1 | 89 | ||||
-rw-r--r-- | tools/strtoll.c | 166 | ||||
-rw-r--r-- | tools/strtoull.c | 144 |
16 files changed, 607 insertions, 580 deletions
diff --git a/tools/Makefile.am b/tools/Makefile.am index 9fad7a78..ce88c85f 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,8 +1,13 @@ configdir=$(sysconfdir)/dbus-1 -INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_DAEMONDIR=\"@DBUS_DAEMONDIR@\" -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" +INCLUDES=-I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" -bin_PROGRAMS=dbus-send dbus-monitor dbus-launch dbus-cleanup-sockets dbus-uuidgen +extra_bin_programs= +if DBUS_UNIX +extra_bin_programs += dbus-cleanup-sockets dbus-uuidgen +endif + +bin_PROGRAMS=dbus-launch dbus-send dbus-monitor $(extra_bin_programs) dbus_send_SOURCES= \ dbus-print-message.c \ @@ -14,10 +19,16 @@ dbus_monitor_SOURCES= \ dbus-print-message.c \ dbus-print-message.h +if DBUS_WIN +dbus_launch_SOURCES= \ + dbus-launch-win.c \ + dbus-launch.h +else dbus_launch_SOURCES= \ dbus-launch.c \ dbus-launch-x11.c \ dbus-launch.h +endif dbus_cleanup_sockets_SOURCES= \ dbus-cleanup-sockets.c @@ -37,8 +48,7 @@ dbus_uuidgen_LDFLAGS=@R_DYNAMIC_LDFLAG@ dbus_launch_LDADD= $(DBUS_X_LIBS) $(DBUS_CLIENT_LIBS) dbus_launch_LDFLAGS=@R_DYNAMIC_LDFLAG@ -man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 dbus-cleanup-sockets.1 dbus-uuidgen.1 -EXTRA_DIST = $(man_MANS) run-with-tmp-session-bus.sh +EXTRA_DIST = run-with-tmp-session-bus.sh strtoll.c strtoull.c CLEANFILES = \ run-with-tmp-session-bus.conf diff --git a/tools/Makefile.in b/tools/Makefile.in index 14d048bc..65bd1c91 100644 --- a/tools/Makefile.in +++ b/tools/Makefile.in @@ -35,21 +35,26 @@ PRE_UNINSTALL = : POST_UNINSTALL = : build_triplet = @build@ host_triplet = @host@ -bin_PROGRAMS = dbus-send$(EXEEXT) dbus-monitor$(EXEEXT) \ - dbus-launch$(EXEEXT) dbus-cleanup-sockets$(EXEEXT) \ - dbus-uuidgen$(EXEEXT) +@DBUS_UNIX_TRUE@am__append_1 = dbus-cleanup-sockets dbus-uuidgen +bin_PROGRAMS = dbus-launch$(EXEEXT) dbus-send$(EXEEXT) \ + dbus-monitor$(EXEEXT) $(am__EXEEXT_2) subdir = tools DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in ACLOCAL_M4 = $(top_srcdir)/aclocal.m4 -am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \ - $(top_srcdir)/configure.in +am__aclocal_m4_deps = $(top_srcdir)/m4/libtool.m4 \ + $(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \ + $(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \ + $(top_srcdir)/acinclude.m4 $(top_srcdir)/configure.in am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ $(ACLOCAL_M4) mkinstalldirs = $(install_sh) -d CONFIG_HEADER = $(top_builddir)/config.h CONFIG_CLEAN_FILES = CONFIG_CLEAN_VPATH_FILES = -am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" \ +@DBUS_UNIX_TRUE@am__EXEEXT_1 = dbus-cleanup-sockets$(EXEEXT) \ +@DBUS_UNIX_TRUE@ dbus-uuidgen$(EXEEXT) +am__EXEEXT_2 = $(am__EXEEXT_1) +am__installdirs = "$(DESTDIR)$(bindir)" \ "$(DESTDIR)$(localstatelibdir)" PROGRAMS = $(bin_PROGRAMS) am_dbus_cleanup_sockets_OBJECTS = dbus-cleanup-sockets.$(OBJEXT) @@ -58,8 +63,11 @@ dbus_cleanup_sockets_LDADD = $(LDADD) AM_V_lt = $(am__v_lt_$(V)) am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY)) am__v_lt_0 = --silent -am_dbus_launch_OBJECTS = dbus-launch.$(OBJEXT) \ - dbus-launch-x11.$(OBJEXT) +am__dbus_launch_SOURCES_DIST = dbus-launch.c dbus-launch-x11.c \ + dbus-launch.h dbus-launch-win.c +@DBUS_WIN_FALSE@am_dbus_launch_OBJECTS = dbus-launch.$(OBJEXT) \ +@DBUS_WIN_FALSE@ dbus-launch-x11.$(OBJEXT) +@DBUS_WIN_TRUE@am_dbus_launch_OBJECTS = dbus-launch-win.$(OBJEXT) dbus_launch_OBJECTS = $(am_dbus_launch_OBJECTS) am__DEPENDENCIES_1 = dbus_launch_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) @@ -118,9 +126,9 @@ am__v_GEN_0 = @echo " GEN " $@; SOURCES = $(dbus_cleanup_sockets_SOURCES) $(dbus_launch_SOURCES) \ $(dbus_monitor_SOURCES) $(dbus_send_SOURCES) \ $(dbus_uuidgen_SOURCES) -DIST_SOURCES = $(dbus_cleanup_sockets_SOURCES) $(dbus_launch_SOURCES) \ - $(dbus_monitor_SOURCES) $(dbus_send_SOURCES) \ - $(dbus_uuidgen_SOURCES) +DIST_SOURCES = $(dbus_cleanup_sockets_SOURCES) \ + $(am__dbus_launch_SOURCES_DIST) $(dbus_monitor_SOURCES) \ + $(dbus_send_SOURCES) $(dbus_uuidgen_SOURCES) am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \ @@ -142,9 +150,6 @@ am__nobase_list = $(am__nobase_strip_setup); \ am__base_list = \ sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \ sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g' -man1dir = $(mandir)/man1 -NROFF = nroff -MANS = $(man_MANS) DATA = $(localstatelib_DATA) ETAGS = etags CTAGS = ctags @@ -153,10 +158,13 @@ ACLOCAL = @ACLOCAL@ AMTAR = @AMTAR@ AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@ AR = @AR@ +AS = @AS@ AUTOCONF = @AUTOCONF@ AUTOHEADER = @AUTOHEADER@ AUTOMAKE = @AUTOMAKE@ AWK = @AWK@ +BUILD_FILEVERSION = @BUILD_FILEVERSION@ +BUILD_TIMESTAMP = @BUILD_TIMESTAMP@ CC = @CC@ CCDEPMODE = @CCDEPMODE@ CFLAGS = @CFLAGS@ @@ -188,6 +196,8 @@ DBUS_MAJOR_VERSION = @DBUS_MAJOR_VERSION@ DBUS_MICRO_VERSION = @DBUS_MICRO_VERSION@ DBUS_MINOR_VERSION = @DBUS_MINOR_VERSION@ DBUS_PATH_OR_ABSTRACT = @DBUS_PATH_OR_ABSTRACT@ +DBUS_PREFIX = @DBUS_PREFIX@ +DBUS_SESSION_BUS_DEFAULT_ADDRESS = @DBUS_SESSION_BUS_DEFAULT_ADDRESS@ DBUS_SESSION_SOCKET_DIR = @DBUS_SESSION_SOCKET_DIR@ DBUS_SYSTEM_BUS_DEFAULT_ADDRESS = @DBUS_SYSTEM_BUS_DEFAULT_ADDRESS@ DBUS_SYSTEM_PID_FILE = @DBUS_SYSTEM_PID_FILE@ @@ -201,6 +211,7 @@ DBUS_X_CFLAGS = @DBUS_X_CFLAGS@ DBUS_X_LIBS = @DBUS_X_LIBS@ DEFS = @DEFS@ DEPDIR = @DEPDIR@ +DLLTOOL = @DLLTOOL@ DOXYGEN = @DOXYGEN@ DSYMUTIL = @DSYMUTIL@ DUMPBIN = @DUMPBIN@ @@ -214,6 +225,7 @@ EXPANDED_DATADIR = @EXPANDED_DATADIR@ EXPANDED_LIBDIR = @EXPANDED_LIBDIR@ EXPANDED_LIBEXECDIR = @EXPANDED_LIBEXECDIR@ EXPANDED_LOCALSTATEDIR = @EXPANDED_LOCALSTATEDIR@ +EXPANDED_PREFIX = @EXPANDED_PREFIX@ EXPANDED_SYSCONFDIR = @EXPANDED_SYSCONFDIR@ FGREP = @FGREP@ GETTEXT_PACKAGE = @GETTEXT_PACKAGE@ @@ -223,6 +235,8 @@ INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ INSTALL_SCRIPT = @INSTALL_SCRIPT@ INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@ +LAUNCHCTL = @LAUNCHCTL@ +LAUNCHD_AGENT_DIR = @LAUNCHD_AGENT_DIR@ LD = @LD@ LDFLAGS = @LDFLAGS@ LIBOBJS = @LIBOBJS@ @@ -238,6 +252,7 @@ LT_CURRENT = @LT_CURRENT@ LT_REVISION = @LT_REVISION@ MAINT = @MAINT@ MAKEINFO = @MAKEINFO@ +MAN2HTML = @MAN2HTML@ MKDIR_P = @MKDIR_P@ NM = @NM@ NMEDIT = @NMEDIT@ @@ -250,6 +265,7 @@ PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@ PACKAGE_NAME = @PACKAGE_NAME@ PACKAGE_STRING = @PACKAGE_STRING@ PACKAGE_TARNAME = @PACKAGE_TARNAME@ +PACKAGE_URL = @PACKAGE_URL@ PACKAGE_VERSION = @PACKAGE_VERSION@ PATH_SEPARATOR = @PATH_SEPARATOR@ PIC_CFLAGS = @PIC_CFLAGS@ @@ -279,6 +295,7 @@ TEST_SOCKET_DIR = @TEST_SOCKET_DIR@ TEST_VALID_SERVICE_DIR = @TEST_VALID_SERVICE_DIR@ TEST_VALID_SERVICE_SYSTEM_DIR = @TEST_VALID_SERVICE_SYSTEM_DIR@ VERSION = @VERSION@ +WINDRES = @WINDRES@ XMKMF = @XMKMF@ XMLTO = @XMLTO@ X_CFLAGS = @X_CFLAGS@ @@ -334,12 +351,14 @@ sbindir = @sbindir@ sharedstatedir = @sharedstatedir@ srcdir = @srcdir@ sysconfdir = @sysconfdir@ +systemdsystemunitdir = @systemdsystemunitdir@ target_alias = @target_alias@ top_build_prefix = @top_build_prefix@ top_builddir = @top_builddir@ top_srcdir = @top_srcdir@ configdir = $(sysconfdir)/dbus-1 -INCLUDES = -I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_DAEMONDIR=\"@DBUS_DAEMONDIR@\" -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" +INCLUDES = -I$(top_srcdir) $(DBUS_CLIENT_CFLAGS) $(DBUS_X_CFLAGS) -DDBUS_LOCALEDIR=\"@EXPANDED_DATADIR@/locale\" -DDBUS_COMPILATION -DDBUS_MACHINE_UUID_FILE=\""$(localstatedir)/lib/dbus/machine-id"\" +extra_bin_programs = $(am__append_1) dbus_send_SOURCES = \ dbus-print-message.c \ dbus-print-message.h \ @@ -350,10 +369,14 @@ dbus_monitor_SOURCES = \ dbus-print-message.c \ dbus-print-message.h -dbus_launch_SOURCES = \ - dbus-launch.c \ - dbus-launch-x11.c \ - dbus-launch.h +@DBUS_WIN_FALSE@dbus_launch_SOURCES = \ +@DBUS_WIN_FALSE@ dbus-launch.c \ +@DBUS_WIN_FALSE@ dbus-launch-x11.c \ +@DBUS_WIN_FALSE@ dbus-launch.h + +@DBUS_WIN_TRUE@dbus_launch_SOURCES = \ +@DBUS_WIN_TRUE@ dbus-launch-win.c \ +@DBUS_WIN_TRUE@ dbus-launch.h dbus_cleanup_sockets_SOURCES = \ dbus-cleanup-sockets.c @@ -369,8 +392,7 @@ dbus_uuidgen_LDADD = $(top_builddir)/dbus/libdbus-1.la $(DBUS_CLIENT_LIBS) dbus_uuidgen_LDFLAGS = @R_DYNAMIC_LDFLAG@ dbus_launch_LDADD = $(DBUS_X_LIBS) $(DBUS_CLIENT_LIBS) dbus_launch_LDFLAGS = @R_DYNAMIC_LDFLAG@ -man_MANS = dbus-send.1 dbus-monitor.1 dbus-launch.1 dbus-cleanup-sockets.1 dbus-uuidgen.1 -EXTRA_DIST = $(man_MANS) run-with-tmp-session-bus.sh +EXTRA_DIST = run-with-tmp-session-bus.sh strtoll.c strtoull.c CLEANFILES = \ run-with-tmp-session-bus.conf @@ -478,6 +500,7 @@ distclean-compile: -rm -f *.tab.c @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-cleanup-sockets.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-launch-win.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-launch-x11.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-launch.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dbus-monitor.Po@am__quote@ @@ -514,44 +537,6 @@ mostlyclean-libtool: clean-libtool: -rm -rf .libs _libs -install-man1: $(man_MANS) - @$(NORMAL_INSTALL) - test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)" - @list=''; test -n "$(man1dir)" || exit 0; \ - { for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.1[a-z]*$$/p'; \ - } | while read p; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - echo "$$d$$p"; echo "$$p"; \ - done | \ - sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \ - sed 'N;N;s,\n, ,g' | { \ - list=; while read file base inst; do \ - if test "$$base" = "$$inst"; then list="$$list $$file"; else \ - echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \ - $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \ - fi; \ - done; \ - for i in $$list; do echo "$$i"; done | $(am__base_list) | \ - while read files; do \ - test -z "$$files" || { \ - echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \ - $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \ - done; } - -uninstall-man1: - @$(NORMAL_UNINSTALL) - @list=''; test -n "$(man1dir)" || exit 0; \ - files=`{ for i in $$list; do echo "$$i"; done; \ - l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \ - sed -n '/\.1[a-z]*$$/p'; \ - } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \ - -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \ - test -z "$$files" || { \ - echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \ - cd "$(DESTDIR)$(man1dir)" && rm -f $$files; } install-localstatelibDATA: $(localstatelib_DATA) @$(NORMAL_INSTALL) test -z "$(localstatelibdir)" || $(MKDIR_P) "$(DESTDIR)$(localstatelibdir)" @@ -626,19 +611,6 @@ distclean-tags: -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags distdir: $(DISTFILES) - @list='$(MANS)'; if test -n "$$list"; then \ - list=`for p in $$list; do \ - if test -f $$p; then d=; else d="$(srcdir)/"; fi; \ - if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \ - if test -n "$$list" && \ - grep 'ab help2man is required to generate this page' $$list >/dev/null; then \ - echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \ - grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/ /' >&2; \ - echo " to fix them, install help2man, remove and regenerate the man pages;" >&2; \ - echo " typically \`make maintainer-clean' will remove them" >&2; \ - exit 1; \ - else :; fi; \ - else :; fi @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \ list='$(DISTFILES)'; \ @@ -670,9 +642,9 @@ distdir: $(DISTFILES) done check-am: all-am check: check-am -all-am: Makefile $(PROGRAMS) $(MANS) $(DATA) +all-am: Makefile $(PROGRAMS) $(DATA) installdirs: - for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)" "$(DESTDIR)$(localstatelibdir)"; do \ + for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(localstatelibdir)"; do \ test -z "$$dir" || $(MKDIR_P) "$$dir"; \ done install: install-am @@ -723,7 +695,7 @@ info: info-am info-am: -install-data-am: install-localstatelibDATA install-man +install-data-am: install-localstatelibDATA install-dvi: install-dvi-am @@ -739,7 +711,7 @@ install-info: install-info-am install-info-am: -install-man: install-man1 +install-man: install-pdf: install-pdf-am @@ -769,10 +741,7 @@ ps: ps-am ps-am: -uninstall-am: uninstall-binPROGRAMS uninstall-localstatelibDATA \ - uninstall-man - -uninstall-man: uninstall-man1 +uninstall-am: uninstall-binPROGRAMS uninstall-localstatelibDATA .MAKE: install-am install-strip @@ -783,13 +752,13 @@ uninstall-man: uninstall-man1 install-binPROGRAMS install-data install-data-am install-dvi \ install-dvi-am install-exec install-exec-am install-html \ install-html-am install-info install-info-am \ - install-localstatelibDATA install-man install-man1 install-pdf \ + install-localstatelibDATA install-man install-pdf \ install-pdf-am install-ps install-ps-am install-strip \ installcheck installcheck-am installdirs maintainer-clean \ maintainer-clean-generic mostlyclean mostlyclean-compile \ mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \ tags uninstall uninstall-am uninstall-binPROGRAMS \ - uninstall-localstatelibDATA uninstall-man uninstall-man1 + uninstall-localstatelibDATA # Tell versions [3.59,3.63) of GNU make to not export all variables. diff --git a/tools/dbus-cleanup-sockets.1 b/tools/dbus-cleanup-sockets.1 deleted file mode 100644 index ca669f49..00000000 --- a/tools/dbus-cleanup-sockets.1 +++ /dev/null @@ -1,43 +0,0 @@ -.\" -.\" dbus-cleanup-sockets manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus-cleanup-sockets 1 -.SH NAME -dbus-cleanup-sockets \- clean up leftover sockets in a directory -.SH SYNOPSIS -.PP -.B dbus-cleanup-sockets [DIRECTORY] - -.SH DESCRIPTION - -The \fIdbus-cleanup-sockets\fP command cleans up unused D-Bus -connection sockets. See http://www.freedesktop.org/software/dbus/ for -more information about the big picture. - -.PP -If given no arguments, \fIdbus-cleanup-sockets\fP cleans up sockets -in the standard default socket directory for the -per-user-login-session message bus; this is usually /tmp. -Optionally, you can pass a different directory on the command line. - -.PP -On Linux, this program is essentially useless, because D-Bus defaults -to using "abstract sockets" that exist only in memory and don't have a -corresponding file in /tmp. - -.PP -On most other flavors of UNIX, it's possible for the socket files to -leak when programs using D-Bus exit abnormally or without closing -their D-Bus connections. Thus, it might be interesting to run -dbus-cleanup-sockets in a cron job to mop up any leaked sockets. -Or you can just ignore the leaked sockets, they aren't really hurting -anything, other than cluttering the output of "ls /tmp" - -.SH AUTHOR -dbus-cleanup-sockets was adapted by Havoc Pennington from -linc-cleanup-sockets written by Michael Meeks. - -.SH BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c new file mode 100644 index 00000000..ea4bf0dd --- /dev/null +++ b/tools/dbus-launch-win.c @@ -0,0 +1,170 @@ +/* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ +/* dbus-launch-win.c dbus-launch utility + * + * Copyright (C) 2007 Ralf Habacker <ralf.habacker@freenet.de> + * + * Licensed under the Academic Free License version 2.1 + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include <config.h> +#ifndef UNICODE +#define UNICODE 1 +#endif +#include <windows.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> + +/* Save string functions. Instead of figuring out the exact _MSC_VER + that work, override for everybody. */ + +#define errno_t int +#define wcscat_s my_wcscat_s +#define wcscpy_s my_wcscpy_s + +static errno_t +wcscat_s (wchar_t *dest, size_t size, wchar_t *src) +{ + assert (sizeof (wchar_t) * (wcslen (dest) + wcslen (src) + 1) <= size); + wcscat (dest, src); + return 0; +} + + +static errno_t +wcscpy_s (wchar_t *dest, size_t size, wchar_t *src) +{ + assert (sizeof (wchar_t) * (wcslen (src) + 1) <= size); + wcscpy (dest, src); + return 0; +} + +/* TODO (tl): This Windows version of dbus-launch is curretly rather + * pointless as it doesn't take the same command-line options as the + * UNIX dbus-launch does. A main point of the dbus-launch command is + * to pass it for instance a --config-file option to make the started + * dbus-daemon use that config file. + * + * This version also doesn't print out any information, which is a + * main point of the UNIX one. It should at least support the + * --sh-syntax option, and maybe also a --cmd-syntax to print out the + * variable settings in cmd.exe syntax? + * + * NOTE (rh): The main task of dbus-launch is (from the man page) to start + * a session bus and this is archieved by the current implemention. + * + * Additional on windows the session bus starting in not integrated + * into the logon process, so there is no need for any --syntax option. + * In fact (at least for kde on windows) the session bus is autostarted + * with the first application requesting a session bus. + * + */ + +#define AUTO_ACTIVATE_CONSOLE_WHEN_VERBOSE_MODE 1 + +#define DIM(x) (sizeof(x) / sizeof(x[0])) +#define WCSTRINGIFY_(x) L ## x +#define WCSTRINGIFY(x) WCSTRINGIFY_(x) + +int +main (int argc, char **argv) +{ + wchar_t dbusDaemonPath[MAX_PATH * 2 + 1]; + wchar_t command[MAX_PATH * 2 + 1]; + wchar_t *p; + wchar_t *daemon_name; + int result; + int showConsole = 0; +#ifdef DBUS_WINCE + char *s = NULL; +#else + char *s = getenv("DBUS_VERBOSE"); +#endif + int verbose = s && *s != '\0' ? 1 : 0; + + PROCESS_INFORMATION pi; + STARTUPINFOW si; + BOOL inherit = TRUE; + DWORD flags = 0; + +#ifdef AUTO_ACTIVATE_CONSOLE_WHEN_VERBOSE_MODE + if (verbose) + showConsole = 1; +#endif + GetModuleFileNameW (NULL, dbusDaemonPath, DIM (dbusDaemonPath)); + + daemon_name = WCSTRINGIFY(DBUS_DAEMON_NAME) L".exe"; + + if ((p = wcsrchr (dbusDaemonPath, L'\\'))) + { + p[1] = L'\0'; + wcscat_s (dbusDaemonPath, sizeof (dbusDaemonPath), daemon_name); + } + else + { + if (verbose) + fprintf (stderr, "error: could not extract path from current " + "applications module filename\n"); + return 1; + } + +#ifdef DBUS_WINCE + /* Windows CE has a different interpretation of cmdline: Start with argv[1]. */ + wcscpy_s (command, sizeof (command), L"--session"); + if (verbose) + fprintf (stderr, "%ls %ls\n", dbusDaemonPath, command); +#else + command[0] = L'\0'; + /* Windows CE has a different interpretation of cmdline: Start with argv[1]. */ + wcscpy_s (command, sizeof (command), dbusDaemonPath); + wcscat_s (command, sizeof (command), L" --session"); + if (verbose) + fprintf (stderr, "%ls\n", command); +#endif + + memset (&si, 0, sizeof (si)); + memset (&pi, 0, sizeof (pi)); + si.cb = sizeof (si); + + if (verbose) + flags |= CREATE_NEW_CONSOLE; + +#ifdef DBUS_WINCE + inherit = FALSE; +#else + flags |= NORMAL_PRIORITY_CLASS; + if (!verbose) + flags |= DETACHED_PROCESS; +#endif + + result = CreateProcessW (dbusDaemonPath, command, 0, 0, + inherit, flags, 0, 0, &si, &pi); + + if (result == 0) + { + if (verbose) + fprintf (stderr, "Could not start " DBUS_DAEMON_NAME ". error=%d\n", + GetLastError ()); + return 4; + } + + CloseHandle (pi.hProcess); + CloseHandle (pi.hThread); + + return 0; +} diff --git a/tools/dbus-launch-x11.c b/tools/dbus-launch-x11.c index 56d7f744..fe492227 100644 --- a/tools/dbus-launch-x11.c +++ b/tools/dbus-launch-x11.c @@ -20,6 +20,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ + +#include <config.h> #include "dbus-launch.h" #ifdef DBUS_BUILD_X11 @@ -459,5 +461,7 @@ x11_handle_event (void) } #else +void dummy_dbus_launch_x11 (void); + void dummy_dbus_launch_x11 (void) { } #endif diff --git a/tools/dbus-launch.1 b/tools/dbus-launch.1 deleted file mode 100644 index 0ea19495..00000000 --- a/tools/dbus-launch.1 +++ /dev/null @@ -1,183 +0,0 @@ -.\" -.\" dbus-launch manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus-launch 1 -.SH NAME -dbus-launch \- Utility to start a message bus from a shell script -.SH SYNOPSIS -.PP -.B dbus-launch [\-\-version] [\-\-sh-syntax] [\-\-csh-syntax] [\-\-auto-syntax] [\-\-exit-with-session] [\-\-autolaunch=MACHINEID] [\-\-config-file=FILENAME] [PROGRAM] [ARGS...] - -.SH DESCRIPTION - -The \fIdbus-launch\fP command is used to start a session bus -instance of \fIdbus-daemon\fP from a shell script. -It would normally be called from a user's login -scripts. Unlike the daemon itself, \fIdbus-launch\fP exits, so -backticks or the $() construct can be used to read information from -\fIdbus-launch\fP. - -With no arguments, \fIdbus-launch\fP will launch a session bus -instance and print the address and pid of that instance to standard -output. - -You may specify a program to be run; in this case, \fIdbus-launch\fP -will launch a session bus instance, set the appropriate environment -variables so the specified program can find the bus, and then execute the -specified program, with the specified arguments. See below for -examples. - -If you launch a program, \fIdbus-launch\fP will not print the -information about the new bus to standard output. - -When \fIdbus-launch\fP prints bus information to standard output, by -default it is in a simple key-value pairs format. However, you may -request several alternate syntaxes using the \-\-sh-syntax, \-\-csh-syntax, -\-\-binary-syntax, or -\-\-auto-syntax options. Several of these cause \fIdbus-launch\fP to emit shell code -to set up the environment. - -With the \-\-auto-syntax option, \fIdbus-launch\fP looks at the value -of the SHELL environment variable to determine which shell syntax -should be used. If SHELL ends in "csh", then csh-compatible code is -emitted; otherwise Bourne shell code is emitted. Instead of passing -\-\-auto-syntax, you may explicity specify a particular one by using -\-\-sh-syntax for Bourne syntax, or \-\-csh-syntax for csh syntax. -In scripts, it's more robust to avoid \-\-auto-syntax and you hopefully -know which shell your script is written in. - -.PP -See http://www.freedesktop.org/software/dbus/ for more information -about D-Bus. See also the man page for \fIdbus-daemon\fP. - -.PP -Here is an example of how to use \fIdbus-launch\fP with an -sh-compatible shell to start the per-session bus daemon: -.nf - - ## test for an existing bus daemon, just to be safe - if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then - ## if not found, launch a new one - eval `dbus-launch --sh-syntax --exit-with-session` - echo "D-Bus per-session daemon address is: $DBUS_SESSION_BUS_ADDRESS" - fi - -.fi -You might run something like that in your login scripts. - -.PP -Another way to use \fIdbus-launch\fP is to run your main session -program, like so: -.nf - -dbus-launch gnome-session - -.fi -The above would likely be appropriate for ~/.xsession or ~/.Xclients. - -.SH AUTOMATIC LAUNCHING - -.PP -If DBUS_SESSION_BUS_ADDRESS is not set for a process that tries to use -D-Bus, by default the process will attempt to invoke dbus-launch with -the --autolaunch option to start up a new session bus or find the -existing bus address on the X display or in a file in -~/.dbus/session-bus/ - -.PP -Whenever an autolaunch occurs, the application that had to -start a new bus will be in its own little world; it can effectively -end up starting a whole new session if it tries to use a lot of -bus services. This can be suboptimal or even totally broken, depending -on the app and what it tries to do. - -.PP -There are two common reasons for autolaunch. One is ssh to a remote -machine. The ideal fix for that would be forwarding of -DBUS_SESSION_BUS_ADDRESS in the same way that DISPLAY is forwarded. -In the meantime, you can edit the session.conf config file to -have your session bus listen on TCP, and manually set -DBUS_SESSION_BUS_ADDRESS, if you like. - -.PP -The second common reason for autolaunch is an su to another user, and -display of X applications running as the second user on the display -belonging to the first user. Perhaps the ideal fix in this case -would be to allow the second user to connect to the session bus of the -first user, just as they can connect to the first user's display. -However, a mechanism for that has not been coded. - -.PP -You can always avoid autolaunch by manually setting -DBUS_SESSION_BUS_ADDRESS. Autolaunch happens because the default -address if none is set is "autolaunch:", so if any other address is -set there will be no autolaunch. You can however include autolaunch in -an explicit session bus address as a fallback, for example -DBUS_SESSION_BUS_ADDRESS="something:,autolaunch:" - in that case if -the first address doesn't work, processes will autolaunch. (The bus -address variable contains a comma-separated list of addresses to try.) - -.PP -The --autolaunch option is considered an internal implementation -detail of libdbus, and in fact there are plans to change it. There's -no real reason to use it outside of the libdbus implementation anyhow. - -.SH OPTIONS -The following options are supported: -.TP -.I "--auto-syntax" -Choose \-\-csh-syntax or \-\-sh-syntax based on the SHELL environment variable. - -.I "--binary-syntax" -Write to stdout a nul-terminated bus address, then the bus PID as a -binary integer of size sizeof(pid_t), then the bus X window ID as a -binary integer of size sizeof(long). Integers are in the machine's -byte order, not network byte order or any other canonical byte order. - -.TP -.I "--close-stderr" -Close the standard error output stream before starting the D-Bus -daemon. This is useful if you want to capture dbus-launch error -messages but you don't want dbus-daemon to keep the stream open to -your application. - -.TP -.I "--config-file=FILENAME" -Pass \-\-config-file=FILENAME to the bus daemon, instead of passing it -the \-\-session argument. See the man page for dbus-daemon - -.TP -.I "--csh-syntax" -Emit csh compatible code to set up environment variables. - -.TP -.I "--exit-with-session" -If this option is provided, a persistent "babysitter" process will be -created that watches stdin for HUP and tries to connect to the X -server. If this process gets a HUP on stdin or loses its X connection, -it kills the message bus daemon. - -.TP -.I "--autolaunch=MACHINEID" -This option implies that \fIdbus-launch\fP should scan for a -previously-started session and reuse the values found there. If no -session is found, it will start a new session. The -\-\-exit-with-session option is implied if \-\-autolaunch is given. -This option is for the exclusive use of libdbus, you do not want to -use it manually. It may change in the future. - -.TP -.I "--sh-syntax" -Emit Bourne-shell compatible code to set up environment variables. - -.TP -.I "--version" -Print the version of dbus-launch - -.SH AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - -.SH BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/tools/dbus-launch.c b/tools/dbus-launch.c index d3553e81..ce9c7b1c 100644 --- a/tools/dbus-launch.c +++ b/tools/dbus-launch.c @@ -21,6 +21,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ + +#include <config.h> #include "dbus-launch.h" #include <stdlib.h> #include <ctype.h> @@ -363,9 +365,9 @@ print_variables (const char *bus_address, pid_t bus_pid, long bus_wid, { if (binary_syntax) { - write (1, bus_address, strlen (bus_address) + 1); - write (1, &bus_pid, sizeof bus_pid); - write (1, &bus_wid, sizeof bus_wid); + do_write (1, bus_address, strlen (bus_address) + 1); + do_write (1, &bus_pid, sizeof bus_pid); + do_write (1, &bus_wid, sizeof bus_wid); return; } else if (c_shell_syntax) @@ -699,7 +701,11 @@ pass_info (const char *runprog, const char *bus_address, pid_t bus_pid, args = malloc (sizeof (char *) * ((argc-remaining_args)+2)); if (envvar == NULL || args == NULL) - goto oom; + { + free (envvar); + free (args); + goto oom; + } args[0] = xstrdup (runprog); if (!args[0]) diff --git a/tools/dbus-launch.h b/tools/dbus-launch.h index d0d0617d..8220bb8e 100644 --- a/tools/dbus-launch.h +++ b/tools/dbus-launch.h @@ -24,7 +24,6 @@ #ifndef DBUS_LAUNCH_H #define DBUS_LAUNCH_H -#include <config.h> #include <sys/types.h> #ifndef TRUE diff --git a/tools/dbus-monitor.1 b/tools/dbus-monitor.1 deleted file mode 100644 index c24c14d9..00000000 --- a/tools/dbus-monitor.1 +++ /dev/null @@ -1,78 +0,0 @@ -.\" -.\" dbus-monitor manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus-monitor 1 -.SH NAME -dbus-monitor \- debug probe to print message bus messages -.SH SYNOPSIS -.PP -.B dbus-monitor -[\-\-system | \-\-session | \-\-address ADDRESS] [\-\-profile | \-\-monitor] -[watch expressions] - -.SH DESCRIPTION - -The \fIdbus-monitor\fP command is used to monitor messages going -through a D-Bus message bus. See -http://www.freedesktop.org/software/dbus/ for more information about -the big picture. - -.PP -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The \-\-system and \-\-session options direct \fIdbus-monitor\fP to -monitor the system or session buses respectively. If neither is -specified, \fIdbus-monitor\fP monitors the session bus. - -.PP -\fIdbus-monitor\fP has two different output modes, the 'classic'-style -monitoring mode and profiling mode. The profiling format is a compact -format with a single line per message and microsecond-resolution timing -information. The \-\-profile and \-\-monitor options select the profiling -and monitoring output format respectively. If neither is specified, -\fIdbus-monitor\fP uses the monitoring output format. - -.PP -In order to get \fIdbus-monitor\fP to see the messages you are interested -in, you should specify a set of watch expressions as you would expect to -be passed to the \fIdbus_bus_add_match\fP function. - -.PP -The message bus configuration may keep \fIdbus-monitor\fP from seeing -all messages, especially if you run the monitor as a non-root user. - -.SH OPTIONS -.TP -.I "--system" -Monitor the system message bus. -.TP -.I "--session" -Monitor the session message bus. (This is the default.) -.TP -.I "--address ADDRESS" -Monitor an arbitrary message bus given at ADDRESS. -.TP -.I "--profile" -Use the profiling output format. -.TP -.I "--monitor" -Use the monitoring output format. (This is the default.) - -.SH EXAMPLE -Here is an example of using dbus-monitor to watch for the gnome typing -monitor to say things -.nf - - dbus-monitor "type='signal',sender='org.gnome.TypingMonitor',interface='org.gnome.TypingMonitor'" - -.fi - -.SH AUTHOR -dbus-monitor was written by Philip Blundell. -The profiling output mode was added by Olli Salli. - -.SH BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/tools/dbus-monitor.c b/tools/dbus-monitor.c index c3681289..3779368a 100644 --- a/tools/dbus-monitor.c +++ b/tools/dbus-monitor.c @@ -41,6 +41,24 @@ #define DBUS_SECONDS_SINCE_1601 11644473600LL #define DBUS_USEC_IN_SEC 1000000LL +#ifdef DBUS_WINCE + +#ifndef _IOLBF +#define _IOLBF 0x40 +#endif +#ifndef _IONBF +#define _IONBF 0x04 +#endif + +void +GetSystemTimeAsFileTime (LPFILETIME ftp) +{ + SYSTEMTIME st; + GetSystemTime (&st); + SystemTimeToFileTime (&st, ftp); +} +#endif + static int gettimeofday (struct timeval *__p, void *__t) @@ -77,7 +95,11 @@ monitor_filter_func (DBusConnection *connection, return DBUS_HANDLER_RESULT_HANDLED; } +#ifdef __APPLE__ +#define PROFILE_TIMED_FORMAT "%s\t%lu\t%d" +#else #define PROFILE_TIMED_FORMAT "%s\t%lu\t%lu" +#endif #define TRAP_NULL_STRING(str) ((str) ? (str) : "<none>") typedef enum @@ -217,7 +239,12 @@ main (int argc, char *argv[]) * do dbus-monitor > file, then send SIGINT via Control-C, they * don't lose the last chunk of messages. */ + +#ifdef DBUS_WIN + setvbuf (stdout, NULL, _IONBF, 0); +#else setvbuf (stdout, NULL, _IOLBF, 0); +#endif for (i = 1; i < argc; i++) { diff --git a/tools/dbus-print-message.c b/tools/dbus-print-message.c index fac5cc1f..75d00aca 100644 --- a/tools/dbus-print-message.c +++ b/tools/dbus-print-message.c @@ -19,6 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * */ + +#include <config.h> #include "dbus-print-message.h" #include <stdlib.h> @@ -54,7 +56,7 @@ indent (int depth) static void print_hex (unsigned char *bytes, unsigned int len, int depth) { - int i, columns; + unsigned int i, columns; printf ("array of bytes [\n"); diff --git a/tools/dbus-send.1 b/tools/dbus-send.1 deleted file mode 100644 index 4878c3d9..00000000 --- a/tools/dbus-send.1 +++ /dev/null @@ -1,95 +0,0 @@ -.\" -.\" dbus-send manual page. -.\" Copyright (C) 2003 Red Hat, Inc. -.\" -.TH dbus-send 1 -.SH NAME -dbus-send \- Send a message to a message bus -.SH SYNOPSIS -.PP -.B dbus-send -[\-\-system | \-\-session] [\-\-dest=NAME] [\-\-print-reply] -[\-\-type=TYPE] <destination object path> <message name> [contents ...] - -.SH DESCRIPTION - -The \fIdbus-send\fP command is used to send a message to a D-Bus message -bus. See http://www.freedesktop.org/software/dbus/ for more -information about the big picture. - -.PP -There are two well-known message buses: the systemwide message bus -(installed on many systems as the "messagebus" service) and the -per-user-login-session message bus (started each time a user logs in). -The \-\-system and \-\-session options direct \fIdbus-send\fP to send -messages to the system or session buses respectively. If neither is -specified, \fIdbus-send\fP sends to the session bus. - -.PP -Nearly all uses of \fIdbus-send\fP must provide the \-\-dest argument -which is the name of a connection on the bus to send the message to. If -\-\-dest is omitted, no destination is set. - -.PP -The object path and the name of the message to send must always be -specified. Following arguments, if any, are the message contents -(message arguments). These are given as type-specified values and -may include containers (arrays, dicts, and variants) as described below. - -.nf -<contents> ::= <item> | <container> [ <item> | <container>...] -<item> ::= <type>:<value> -<container> ::= <array> | <dict> | <variant> -<array> ::= array:<type>:<value>[,<value>...] -<dict> ::= dict:<type>:<type>:<key>,<value>[,<key>,<value>...] -<variant> ::= variant:<type>:<value> -<type> ::= string | int16 | uint 16 | int32 | uint32 | int64 | uint64 | double | byte | boolean | objpath -.fi - -D-Bus supports more types than these, but \fIdbus-send\fP currently -does not. Also, \fIdbus-send\fP does not permit empty containers -or nested containers (e.g. arrays of variants). - -.PP -Here is an example invocation: -.nf - - dbus-send \-\-dest=org.freedesktop.ExampleName \\ - /org/freedesktop/sample/object/name \\ - org.freedesktop.ExampleInterface.ExampleMethod \\ - int32:47 string:'hello world' double:65.32 \\ - array:string:"1st item","next item","last item" \\ - dict:string:int32:"one",1,"two",2,"three",3 \\ - variant:int32:-8 \\ - objpath:/org/freedesktop/sample/object/name - -.fi - -Note that the interface is separated from a method or signal -name by a dot, though in the actual protocol the interface -and the interface member are separate fields. - -.SH OPTIONS -The following options are supported: -.TP -.I "--dest=NAME" -Specify the name of the connection to receive the message. -.TP -.I "--print-reply" -Block for a reply to the message sent, and print any reply received. -.TP -.I "--system" -Send to the system message bus. -.TP -.I "--session" -Send to the session message bus. (This is the default.) -.TP -.I "--type=TYPE" -Specify "method_call" or "signal" (defaults to "signal"). - -.SH AUTHOR -dbus-send was written by Philip Blundell. - -.SH BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/tools/dbus-send.c b/tools/dbus-send.c index c9c9be27..c7d50908 100644 --- a/tools/dbus-send.c +++ b/tools/dbus-send.c @@ -26,6 +26,24 @@ #include <dbus/dbus.h> +#ifndef HAVE_STRTOLL +#undef strtoll +#define strtoll mystrtoll +#include "strtoll.c" +#endif + +#ifndef HAVE_STRTOULL +#undef strtoull +#define strtoull mystrtoull +#include "strtoull.c" +#endif + +#ifdef DBUS_WINCE +#ifndef strdup +#define strdup _strdup +#endif +#endif + #include "dbus-print-message.h" static const char *appname; diff --git a/tools/dbus-uuidgen.1 b/tools/dbus-uuidgen.1 deleted file mode 100644 index 480fd18f..00000000 --- a/tools/dbus-uuidgen.1 +++ /dev/null @@ -1,89 +0,0 @@ -.\" -.\" dbus-uuidgen manual page. -.\" Copyright (C) 2006 Red Hat, Inc. -.\" -.TH dbus-uuidgen 1 -.SH NAME -dbus-uuidgen \- Utility to generate UUIDs -.SH SYNOPSIS -.PP -.B dbus-uuidgen [\-\-version] [\-\-ensure[=FILENAME]] [\-\-get[=FILENAME]] - -.SH DESCRIPTION - -The \fIdbus-uuidgen\fP command generates or reads a universally unique ID. - -.PP -Note that the D-Bus UUID has no relationship to RFC 4122 and does not generate -UUIDs compatible with that spec. Many systems have a separate command -for that (often called "uuidgen"). - -.PP -See http://www.freedesktop.org/software/dbus/ for more information -about D-Bus. - -.PP -The primary usage of \fIdbus-uuidgen\fP is to run in the post-install -script of a D-Bus package like this: -.nf - dbus-uuidgen --ensure -.fi - -.PP -This will ensure that /var/lib/dbus/machine-id exists and has the uuid in it. -It won't overwrite an existing uuid, since this id should remain fixed -for a single machine until the next reboot at least. - -.PP -The important properties of the machine UUID are that 1) it remains -unchanged until the next reboot and 2) it is different for any two -running instances of the OS kernel. That is, if two processes see the -same UUID, they should also see the same shared memory, UNIX domain -sockets, local X displays, localhost.localdomain resolution, process -IDs, and so forth. - -.PP -If you run \fIdbus-uuidgen\fP with no options it just prints a new uuid made -up out of thin air. - -.PP -If you run it with --get, it prints the machine UUID by default, or -the UUID in the specified file if you specify a file. - -.PP -If you try to change an existing machine-id on a running system, it will -probably result in bad things happening. Don't try to change this file. Also, -don't make it the same on two different systems; it needs to be different -anytime there are two different kernels running. - -.PP -The UUID should be different on two different virtual machines, -because there are two different kernels. - -.SH OPTIONS -The following options are supported: -.TP -.I "--get[=FILENAME]" -If a filename is not given, defaults to localstatedir/lib/dbus/machine-id -(localstatedir is usually /var). If this file exists and is valid, the -uuid in the file is printed on stdout. Otherwise, the command exits -with a nonzero status. - -.TP -.I "--ensure[=FILENAME]" -If a filename is not given, defaults to localstatedir/lib/dbus/machine-id -(localstatedir is usually /var). If this file exists then it will be -validated, and a failure code returned if it contains the wrong thing. -If the file does not exist, it will be created with a new uuid in it. -On success, prints no output. - -.TP -.I "--version" -Print the version of dbus-uuidgen - -.SH AUTHOR -See http://www.freedesktop.org/software/dbus/doc/AUTHORS - -.SH BUGS -Please send bug reports to the D-Bus mailing list or bug tracker, -see http://www.freedesktop.org/software/dbus/ diff --git a/tools/strtoll.c b/tools/strtoll.c new file mode 100644 index 00000000..e4f57701 --- /dev/null +++ b/tools/strtoll.c @@ -0,0 +1,166 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include <limits.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <stdlib.h> +#ifdef DBUS_WINCE +#include <windows.h> +#endif + +#ifndef isspace +#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') +#endif + +/* Minimum and maximum values a `signed long long int' can hold. */ +#ifndef LLONG_MAX +# define LLONG_MAX 9223372036854775807LL +#endif + +#ifndef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX - 1LL) +#endif +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +#ifndef ULLONG_MAX +# define ULLONG_MAX 18446744073709551615ULL +#endif +/* + * Convert a string to a long long integer. + * + * Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +long long strtoll (const char*, char **, int); + +long long +strtoll(const char * nptr, char ** endptr, int base) +{ + const char *s; + unsigned long long acc; + char c; + unsigned long long cutoff; + int neg, any, cutlim; + + /* + * Skip white space and pick up leading +/- sign if any. + * If base is 0, allow 0x for hex and 0 for octal, else + * assume decimal; if base is already 16, allow 0x. + */ + s = nptr; + do { + c = *s++; + } while (isspace((unsigned char)c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'A' && s[1] <= 'F') || + (s[1] >= 'a' && s[1] <= 'f'))) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + acc = any = 0; + if (base < 2 || base > 36) + goto noconv; + + /* + * Compute the cutoff value between legal numbers and illegal + * numbers. That is the largest legal value, divided by the + * base. An input number that is greater than this value, if + * followed by a legal input character, is too big. One that + * is equal to this value may be valid or not; the limit + * between valid and invalid numbers is then based on the last + * digit. For instance, if the range for quads is + * [-9223372036854775808..9223372036854775807] and the input base + * is 10, cutoff will be set to 922337203685477580 and cutlim to + * either 7 (neg==0) or 8 (neg==1), meaning that if we have + * accumulated a value > 922337203685477580, or equal but the + * next digit is > 7 (or 8), the number is too big, and we will + * return a range error. + * + * Set 'any' if any `digits' consumed; make it negative to indicate + * overflow. + */ + cutoff = neg ? (unsigned long long)-(LLONG_MIN + LLONG_MAX) + LLONG_MAX + : LLONG_MAX; + cutlim = cutoff % base; + cutoff /= base; + for ( ; ; c = *s++) { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = neg ? LLONG_MIN : LLONG_MAX; +#ifdef DBUS_WINCE + SetLastError (ERROR_ARITHMETIC_OVERFLOW); +#else + errno = ERANGE; +#endif + } else if (!any) { +noconv: +#ifdef DBUS_WINCE + SetLastError (ERROR_INVALID_PARAMETER); +#else + errno = EINVAL; +#endif + } else if (neg) + acc = -acc; + if (endptr != NULL) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} + diff --git a/tools/strtoull.c b/tools/strtoull.c new file mode 100644 index 00000000..459c5091 --- /dev/null +++ b/tools/strtoull.c @@ -0,0 +1,144 @@ +/*- + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + + +#include <limits.h> +#ifdef HAVE_ERRNO_H +#include <errno.h> +#endif +#include <stdlib.h> +#ifdef DBUS_WINCE +#include <windows.h> +#endif + +#ifndef isspace +#define isspace(c) ((c) == ' ' || (c) == '\t' || (c) == '\r' || (c) == '\n') +#endif + +/* Minimum and maximum values a `signed long long int' can hold. */ +#ifndef LLONG_MAX +# define LLONG_MAX 9223372036854775807LL +#endif + +#ifndef LLONG_MIN +# define LLONG_MIN (-LLONG_MAX - 1LL) +#endif +/* Maximum value an `unsigned long long int' can hold. (Minimum is 0.) */ +#ifndef ULLONG_MAX +# define ULLONG_MAX 18446744073709551615ULL +#endif + +/* + * Convert a string to an unsigned long long integer. + * + * Assumes that the upper and lower case + * alphabets and digits are each contiguous. + */ +unsigned long long strtoull (const char *, char **, int); + +unsigned long long +strtoull(const char * nptr, char ** endptr, int base) +{ + const char *s; + unsigned long long acc; + char c; + unsigned long long cutoff; + int neg, any, cutlim; + + /* + * See strtoq for comments as to the logic used. + */ + s = nptr; + do { + c = *s++; + } while (isspace((unsigned char)c)); + if (c == '-') { + neg = 1; + c = *s++; + } else { + neg = 0; + if (c == '+') + c = *s++; + } + if ((base == 0 || base == 16) && + c == '0' && (*s == 'x' || *s == 'X') && + ((s[1] >= '0' && s[1] <= '9') || + (s[1] >= 'A' && s[1] <= 'F') || + (s[1] >= 'a' && s[1] <= 'f'))) { + c = s[1]; + s += 2; + base = 16; + } + if (base == 0) + base = c == '0' ? 8 : 10; + acc = any = 0; + if (base < 2 || base > 36) + goto noconv; + + cutoff = ULLONG_MAX / base; + cutlim = ULLONG_MAX % base; + for ( ; ; c = *s++) { + if (c >= '0' && c <= '9') + c -= '0'; + else if (c >= 'A' && c <= 'Z') + c -= 'A' - 10; + else if (c >= 'a' && c <= 'z') + c -= 'a' - 10; + else + break; + if (c >= base) + break; + if (any < 0 || acc > cutoff || (acc == cutoff && c > cutlim)) + any = -1; + else { + any = 1; + acc *= base; + acc += c; + } + } + if (any < 0) { + acc = ULLONG_MAX; +#ifdef DBUS_WINCE + SetLastError (ERROR_ARITHMETIC_OVERFLOW); +#else + errno = ERANGE; +#endif + } else if (!any) { +noconv: +#ifdef DBUS_WINCE + SetLastError (ERROR_INVALID_PARAMETER); +#else + errno = EINVAL; +#endif + } else if (neg) + acc = -acc; + if (endptr != NULL) + *endptr = (char *)(any ? s - 1 : nptr); + return (acc); +} |