VirtualBox

source: vbox/trunk/src/VBox/Runtime/include/internal/pipe.h@ 96781

Last change on this file since 96781 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1/* $Id: pipe.h 96407 2022-08-22 17:43:14Z vboxsync $ */
2/** @file
3 * IPRT - Internal RTPipe header.
4 */
5
6/*
7 * Copyright (C) 2010-2022 Oracle and/or its affiliates.
8 *
9 * This file is part of VirtualBox base platform packages, as
10 * available from https://www.virtualbox.org.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation, in version 3 of the
15 * License.
16 *
17 * This program is distributed in the hope that it will be useful, but
18 * WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
20 * General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, see <https://www.gnu.org/licenses>.
24 *
25 * The contents of this file may alternatively be used under the terms
26 * of the Common Development and Distribution License Version 1.0
27 * (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
28 * in the VirtualBox distribution, in which case the provisions of the
29 * CDDL are applicable instead of those of the GPL.
30 *
31 * You may elect to license modified versions of this file under the
32 * terms and conditions of either the GPL or the CDDL or both.
33 *
34 * SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
35 */
36
37#ifndef IPRT_INCLUDED_INTERNAL_pipe_h
38#define IPRT_INCLUDED_INTERNAL_pipe_h
39#ifndef RT_WITHOUT_PRAGMA_ONCE
40# pragma once
41#endif
42
43#include <iprt/pipe.h>
44
45RT_C_DECLS_BEGIN
46
47/**
48 * Internal RTPollSetAdd helper that returns the handle that should be added to
49 * the pollset.
50 *
51 * @returns Valid handle on success, INVALID_HANDLE_VALUE on failure.
52 * @param hPipe The pipe handle.
53 * @param fEvents The events we're polling for.
54 * @param phNative Where to put the primary handle.
55 */
56int rtPipePollGetHandle(RTPIPE hPipe, uint32_t fEvents, PRTHCINTPTR phNative);
57
58/**
59 * Internal RTPoll helper that polls the pipe handle and, if @a fNoWait is
60 * clear, starts whatever actions we've got running during the poll call.
61 *
62 * @returns 0 if no pending events, actions initiated if @a fNoWait is clear.
63 * Event mask (in @a fEvents) and no actions if the handle is ready
64 * already.
65 * UINT32_MAX (asserted) if the pipe handle is busy in I/O or a
66 * different poll set.
67 *
68 * @param hPipe The pipe handle.
69 * @param hPollSet The poll set handle (for access checks).
70 * @param fEvents The events we're polling for.
71 * @param fFinalEntry Set if this is the final entry for this handle
72 * in this poll set. This can be used for dealing
73 * with duplicate entries.
74 * @param fNoWait Set if it's a zero-wait poll call. Clear if
75 * we'll wait for an event to occur.
76 */
77uint32_t rtPipePollStart(RTPIPE hPipe, RTPOLLSET hPollSet, uint32_t fEvents, bool fFinalEntry, bool fNoWait);
78
79/**
80 * Called after a WaitForMultipleObjects returned in order to check for pending
81 * events and stop whatever actions that rtPipePollStart() initiated.
82 *
83 * @returns Event mask or 0.
84 *
85 * @param hPipe The pipe handle.
86 * @param fEvents The events we're polling for.
87 * @param fFinalEntry Set if this is the final entry for this handle
88 * in this poll set. This can be used for dealing
89 * with duplicate entries. Only keep in mind that
90 * this method is called in reverse order, so the
91 * first call will have this set (when the entire
92 * set was processed).
93 * @param fHarvestEvents Set if we should check for pending events.
94 */
95uint32_t rtPipePollDone(RTPIPE hPipe, uint32_t fEvents, bool fFinalEntry, bool fHarvestEvents);
96
97
98/**
99 * Fakes basic query info data for RTPipeQueryInfo.
100 *
101 * @param pObjInfo The output structure.
102 * @param enmAddAttr The extra attribute.
103 * @param fReadPipe Set if read pipe, clear if write pipe.
104 */
105DECLINLINE(void) rtPipeFakeQueryInfo(PRTFSOBJINFO pObjInfo, RTFSOBJATTRADD enmAddAttr, bool fReadPipe)
106{
107 RT_ZERO(*pObjInfo);
108 if (fReadPipe)
109 pObjInfo->Attr.fMode = RTFS_TYPE_FIFO | RTFS_UNIX_IRUSR | RTFS_DOS_READONLY;
110 else
111 pObjInfo->Attr.fMode = RTFS_TYPE_FIFO | RTFS_UNIX_IWUSR;
112 pObjInfo->Attr.enmAdditional = enmAddAttr;
113 switch (enmAddAttr)
114 {
115 case RTFSOBJATTRADD_UNIX:
116 pObjInfo->Attr.u.Unix.cHardlinks = 1;
117 break;
118 case RTFSOBJATTRADD_UNIX_OWNER:
119 pObjInfo->Attr.u.UnixOwner.uid = NIL_RTUID;
120 break;
121 case RTFSOBJATTRADD_UNIX_GROUP:
122 pObjInfo->Attr.u.UnixGroup.gid = NIL_RTGID;
123 break;
124 case RTFSOBJATTRADD_EASIZE:
125 break;
126 case RTFSOBJATTRADD_32BIT_SIZE_HACK:
127 case RTFSOBJATTRADD_NOTHING:
128 /* shut up gcc. */
129 break;
130 /* no default, want warnings. */
131 }
132}
133
134
135RT_C_DECLS_END
136
137#endif /* !IPRT_INCLUDED_INTERNAL_pipe_h */
138
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette