diff options
| -rw-r--r-- | ChangeLog | 4 | ||||
| -rw-r--r-- | cmake/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | cmake/tools/CMakeLists.txt | 10 | ||||
| -rw-r--r-- | tools/dbus-launch-win.c | 119 | 
4 files changed, 133 insertions, 2 deletions
@@ -1,3 +1,7 @@ +2007-06-01  Ralf Habacker  <ralf.habacker@freenet.de> + +	* tools/dbus-launch-win.c: new file, replaces script wrapper on win32. +  2007-05-31  Ralf Habacker  <ralf.habacker@freenet.de>  	* bus/main.c (main): uses _dbus_get_config_file_name() to detect  diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 6cc0ac8c..1df49f64 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -423,9 +423,7 @@ endif(MINGW)  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h )  configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-env.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-env.bat ) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/dbus-launch.bat.cmake ${CMAKE_BINARY_DIR}/bin/dbus-launch.bat )  install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-env.bat)	 -install_files(/bin FILES ${CMAKE_BINARY_DIR}/bin/dbus-launch.bat)	  # compiler definitions   add_definitions(-DHAVE_CONFIG_H=1) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index c5568cb3..adff9306 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -38,9 +38,15 @@ set (dbus_monitor_SOURCES  	../../tools/dbus-print-message.h  ) +if (WIN32) +set (dbus_launch_SOURCES +	../../tools/dbus-launch-win.c +) +else (WIN32)  set (dbus_launch_SOURCES  	../../tools/dbus-launch.c  ) +endif (WIN32)  set (dbus_cleanup_sockets_SOURCES  	../../tools/dbus-cleanup-sockets.c @@ -61,6 +67,10 @@ install_targets(/bin dbus-send${CMAKE_EXE_POSTFIX} )  # glib required   #add_executable(dbus_launch${CMAKE_EXE_POSTFIX} ${dbus_launch_SOURCES}) +add_executable(dbus-launch${CMAKE_EXE_POSTFIX} ${dbus_launch_SOURCES}) +target_link_libraries(dbus-launch${CMAKE_EXE_POSTFIX} ) +install_targets(/bin dbus-launch${CMAKE_EXE_POSTFIX} ) +  add_executable(dbus-monitor${CMAKE_EXE_POSTFIX} ${dbus_monitor_SOURCES})  target_link_libraries(dbus-monitor${CMAKE_EXE_POSTFIX} dbus-1)  install_targets(/bin dbus-monitor${CMAKE_EXE_POSTFIX} ) diff --git a/tools/dbus-launch-win.c b/tools/dbus-launch-win.c new file mode 100644 index 00000000..972ad278 --- /dev/null +++ b/tools/dbus-launch-win.c @@ -0,0 +1,119 @@ +/* -*- mode: C; c-file-style: "gnu" -*- */ +/* dbus-launch.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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA + * + */ +#include <windows.h> +#include <stdio.h> +#include <string.h> +#include <assert.h> + +#ifdef __MINGW32__ +/* save string functions version +*/  +#define errno_t int + +errno_t strcat_s(char *dest, int size, char *src)  +{ +  assert(strlen(dest) + strlen(src) +1 <= size); +  strcat(dest,src); +  return 0; +} + +errno_t strcpy_s(char *dest, int size, char *src) +{ +  assert(strlen(src) +1 <= size); +  strcpy(dest,src);   +  return 0; +} +#endif + +/* TODO: use unicode version as suggested by Tor Lillqvist */ + +#define AUTO_ACTIVATE_CONSOLE_WHEN_VERBOSE_MODE 1 + +int main(int argc,char **argv) +{ +  char dbusDaemonPath[MAX_PATH*2+1]; +  char command[MAX_PATH*2+1]; +  char *p; +  char *daemon_name; +  int result; +  int showConsole = 0; +  char *s = getenv("DBUS_VERBOSE"); +  int verbose = s && *s != '\0' ? 1 : 0; +  PROCESS_INFORMATION pi; +  STARTUPINFO si; +  HANDLE h;  +   +#ifdef AUTO_ACTIVATE_CONSOLE_WHEN_VERBOSE_MODE +  if (verbose) +      showConsole = 1;  +#endif +  GetModuleFileName(NULL,dbusDaemonPath,sizeof(dbusDaemonPath)); +  /* check for debug version */ +  if (strstr(dbusDaemonPath,"dbus-launchd.exe")) +      daemon_name = "dbus-daemond.exe"; +  else +      daemon_name = "dbus-daemon.exe"; +  if ((p = strrchr(dbusDaemonPath,'\\')))  +    { +      *(p+1)= '\0'; +      strcat_s(dbusDaemonPath,sizeof(dbusDaemonPath),daemon_name); +    } +  else  +    { +      if (verbose) +          fprintf(stderr,"error: could not extract path from current applications module filename\n"); +      return 1; +    }  +   +  strcpy_s(command,sizeof(command),dbusDaemonPath); +  strcat_s(command,sizeof(command)," --session"); +  if (verbose) +      fprintf(stderr,"%s\n",command); +   +  memset(&si, 0, sizeof(si)); +  memset(&pi, 0, sizeof(pi)); +  si.cb = sizeof(si); + +  result = CreateProcess(NULL,  +                  command, +                  0, +                  0, +                  TRUE, +                  (showConsole ? CREATE_NEW_CONSOLE : 0) | NORMAL_PRIORITY_CLASS, +                  0, +                  0, +                  &si, +                  &pi); + +  CloseHandle(pi.hProcess); +  CloseHandle(pi.hThread); + +  if (result == 0)  +    { +      if (verbose) +          fprintf(stderr,"could not start dbus-daemon error=%d",GetLastError()); +      return 4; +    } +    +  return 0; +}  | 
