• Main Page
  • Related Pages
  • Modules
  • Data Structures
  • Files
  • File List

dbus-pipe-win.c

00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */
00002 /* dbus-pipe-win.c windows related pipe implementation
00003  * 
00004  * Copyright (C) 2002, 2003, 2006  Red Hat, Inc.
00005  * Copyright (C) 2003 CodeFactory AB
00006  *
00007  * Licensed under the Academic Free License version 2.1
00008  * 
00009  * This program is free software; you can redistribute it and/or modify
00010  * it under the terms of the GNU General Public License as published by
00011  * the Free Software Foundation; either version 2 of the License, or
00012  * (at your option) any later version.
00013  *
00014  * This program is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  * GNU General Public License for more details.
00018  * 
00019  * You should have received a copy of the GNU General Public License
00020  * along with this program; if not, write to the Free Software
00021  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
00022  *
00023  */
00024 
00025 #include <config.h>
00026 #include "dbus-protocol.h"
00027 #include "dbus-string.h"
00028 #include "dbus-internals.h"
00029 #include "dbus-pipe.h"
00030 
00031 #include <windows.h>
00032 
00043 int
00044 _dbus_pipe_write (DBusPipe         *pipe,
00045                   const DBusString *buffer,
00046                   int               start,
00047                   int               len,
00048                   DBusError        *error)
00049 {
00050   DWORD written;
00051   BOOL res;
00052 
00053   const char *buffer_c = _dbus_string_get_const_data (buffer);
00054 
00055   res = WriteFile ((HANDLE) pipe->fd_or_handle, buffer_c + start, len, &written, NULL);
00056   if (res == 0 || written < 0)
00057     {
00058       dbus_set_error (error, DBUS_ERROR_FAILED,
00059                       "Writing to pipe: %s\n",
00060                       _dbus_strerror_from_errno ());
00061     }
00062   return written;
00063 }
00064 
00072 int
00073 _dbus_pipe_close  (DBusPipe         *pipe,
00074                    DBusError        *error)
00075 {
00076   _DBUS_ASSERT_ERROR_IS_CLEAR (error);
00077 
00078   if (CloseHandle ((HANDLE) pipe->fd_or_handle) == 0)
00079     {
00080       dbus_set_error (error, _dbus_error_from_system_errno (),
00081                       "Could not close pipe %d: %s", pipe->fd_or_handle,
00082                       _dbus_strerror_from_errno ());
00083       return -1;
00084     }
00085   else
00086     {
00087       _dbus_pipe_invalidate (pipe);
00088       return 0;
00089     }
00090 }

Generated on Mon Sep 27 2010 22:54:24 for D-Bus by  doxygen 1.7.1