D-Bus 1.4.14
|
00001 /* -*- mode: C; c-file-style: "gnu"; indent-tabs-mode: nil; -*- */ 00002 /* dbus-pipe.c pipe implementation (internal to D-Bus 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-pipe.h" 00027 00028 /* 00029 * init a pipe instance. 00030 * 00031 * @param pipe the pipe 00032 * @param fd the file descriptor to init from 00033 */ 00034 void 00035 _dbus_pipe_init (DBusPipe *pipe, 00036 intptr_t fd) 00037 { 00038 pipe->fd_or_handle = fd; 00039 } 00040 00046 void 00047 _dbus_pipe_init_stdout (DBusPipe *pipe) 00048 { 00049 _dbus_pipe_init (pipe, 1); 00050 } 00051 00059 dbus_bool_t 00060 _dbus_pipe_is_valid(DBusPipe *pipe) 00061 { 00062 return pipe->fd_or_handle >= 0; 00063 } 00064 00071 dbus_bool_t 00072 _dbus_pipe_is_stdout_or_stderr (DBusPipe *pipe) 00073 { 00074 return pipe->fd_or_handle == 1 || pipe->fd_or_handle == 2; 00075 } 00076 00081 void 00082 _dbus_pipe_invalidate (DBusPipe *pipe) 00083 { 00084 pipe->fd_or_handle = -1; 00085 }