
    Ii>                     h    S r SSKrSSKrSSKrS r " S S5      r " S S5      r " S S	5      rS
 rg)a  
Abstraction of a one-way pipe where the read end can be used in
`select.select`. Normally this is trivial, but Windows makes it nearly
impossible.

The pipe acts like an Event, which can be set or cleared. When set, the pipe
will trigger as readable in `select <select.select>`.
    Nc                  `    [         R                  S S S:w  a  [        5       n U $ [        5       n U $ )N   win)sysplatform	PosixPipeWindowsPipe)ps    3/venv/lib/python3.13/site-packages/paramiko/pipe.py	make_piper   !   s1    
||BQ5 K H MH    c                   8    \ rS rSrS rS rS rS rS rS r	Sr
g	)
r   )   c                 r    [         R                  " 5       u  U l        U l        SU l        SU l        SU l        g NF)ospipe_rfd_wfd_set_forever_closedselfs    r   __init__PosixPipe.__init__*   s+    !wwy	49	r   c                     [         R                  " U R                  5        [         R                  " U R                  5        SU l        g NT)r   closer   r   r   r   s    r   r   PosixPipe.close0   s)    

r   c                     U R                   $ N)r   r   s    r   filenoPosixPipe.fileno6   s    yyr   c                     U R                   (       a  U R                  (       a  g [        R                  " U R                  S5        SU l         g N   F)r   r   r   readr   r   s    r   clearPosixPipe.clear9   s+    yyDMM
		1	r   c                     U R                   (       d  U R                  (       a  g SU l         [        R                  " U R                  S5        g NT   *)r   r   r   writer   r   s    r   setPosixPipe.set?   s+    99	
D!r   c                 2    SU l         U R                  5         g r   r   r/   r   s    r   set_foreverPosixPipe.set_foreverE       
r   )r   r   r   r   r   N)__name__
__module____qualname____firstlineno__r   r   r#   r)   r/   r3   __static_attributes__ r   r   r   r   )   s     "r   r   c                   <    \ rS rSrSrS rS rS rS rS r	S r
S	rg
)r	   J   z{
On Windows, only an OS-level "WinSock" may be used in select(), but reads
and writes must be to the actual socket object.
c                    [         R                   " [         R                  [         R                  5      nUR                  S5        UR	                  S5        [         R                   " [         R                  [         R                  5      U l        U R
                  R                  SUR                  5       S   45        UR                  5       u  U l	        nUR                  5         SU l        SU l        SU l        g )N)	127.0.0.1r   r'   r?   F)socketAF_INETSOCK_STREAMbindlisten_rsockconnectgetsocknameaccept_wsockr   r   r   r   )r   servaddrs      r   r   WindowsPipe.__init__P   s    }}V^^V-?-?@		"#A mmFNNF4F4FG[$*:*:*<Q*?@A KKMT

	r   c                 z    U R                   R                  5         U R                  R                  5         SU l        g r   )rE   r   rI   r   r   s    r   r   WindowsPipe.close_   s)    r   c                 6    U R                   R                  5       $ r"   )rE   r#   r   s    r   r#   WindowsPipe.filenoe   s    {{!!##r   c                     U R                   (       a  U R                  (       a  g U R                  R                  S5        SU l         g r&   )r   r   rE   recvr   s    r   r)   WindowsPipe.clearh   s+    yyDMM	r   c                     U R                   (       d  U R                  (       a  g SU l         U R                  R                  S5        g r,   )r   r   rI   sendr   s    r   r/   WindowsPipe.setn   s+    99	r   c                 2    SU l         U R                  5         g r   r2   r   s    r   r3   WindowsPipe.set_forevert   r5   r   )r   r   rE   r   rI   N)r6   r7   r8   r9   __doc__r   r   r#   r)   r/   r3   r:   r;   r   r   r	   r	   J   s%    
$r   r	   c                   &    \ rS rSrS rS rS rSrg)OrPipey   c                 ,    SU l         S U l        Xl        g r   )r   _partner_pipe)r   r   s     r   r   OrPipe.__init__z   s    	
r   c                 ~    SU l         U R                  R                   (       d  U R                  R                  5         g g r   )r   r^   r_   r/   r   s    r   r/   
OrPipe.set   s)    	}}!!JJNN "r   c                 ~    SU l         U R                  R                   (       d  U R                  R                  5         g g r   )r   r^   r_   r)   r   s    r   r)   OrPipe.clear   s+    	}}!!JJ "r   )r^   r_   r   N)r6   r7   r8   r9   r   r/   r)   r:   r;   r   r   r[   r[   y   s    

r   r[   c                 L    [        U 5      n[        U 5      nX!l        Xl        X4$ )z
wraps a pipe into two pipe-like objects which are "or"d together to
affect the real pipe. if either returned pipe is set, the wrapped pipe
is set. when both are cleared, the wrapped pipe is cleared.
)r[   r^   )r   p1p2s      r   make_or_piperh      s'     
B	BKK6Mr   )	rY   r   r   r@   r   r   r	   r[   rh   r;   r   r   <module>ri      s?   &  	  B, ,^ "
r   