o
    ÞÜg>  ã                   @   sZ   d Z ddlZddlZddlZdd„ ZG dd„ dƒZG dd„ dƒZG d	d
„ d
ƒZdd„ ZdS )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                  C   s&   t jd d… dkrtƒ } | S tƒ } | S )Né   Úwin)ÚsysÚplatformÚ	PosixPipeÚWindowsPipe)Úp© r	   úG/var/www/html/api-tag/env/lib/python3.10/site-packages/paramiko/pipe.pyÚ	make_pipe!   s
   ÿr   c                   @   s<   e Zd Zdd„ Zdd„ Zdd„ Zdd„ Zd	d
„ Zdd„ ZdS )r   c                 C   s&   t  ¡ \| _| _d| _d| _d| _d S ©NF)ÚosÚpipeÚ_rfdÚ_wfdÚ_setÚ_foreverÚ_closed©Úselfr	   r	   r
   Ú__init__*   s   
zPosixPipe.__init__c                 C   s"   t  | j¡ t  | j¡ d| _d S ©NT)r   Úcloser   r   r   r   r	   r	   r
   r   0   s   
zPosixPipe.closec                 C   s   | j S ©N)r   r   r	   r	   r
   Úfileno6   s   zPosixPipe.filenoc                 C   s(   | j r| jrd S t | jd¡ d| _ d S ©Né   F)r   r   r   Úreadr   r   r	   r	   r
   Úclear9   s   
zPosixPipe.clearc                 C   s(   | j s| jrd S d| _ t | jd¡ d S ©NTó   *)r   r   r   Úwriter   r   r	   r	   r
   Úset?   s   zPosixPipe.setc                 C   ó   d| _ |  ¡  d S r   ©r   r"   r   r	   r	   r
   Úset_foreverE   ó   zPosixPipe.set_foreverN)	Ú__name__Ú
__module__Ú__qualname__r   r   r   r   r"   r%   r	   r	   r	   r
   r   )   s    r   c                   @   s@   e Zd ZdZdd„ Zdd„ Zdd„ Zdd	„ Zd
d„ Zdd„ Z	dS )r   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                 C   sz   t   t jt j¡}| d¡ | d¡ t   t jt j¡| _| j d| ¡ d f¡ | ¡ \| _	}| 
¡  d| _d| _d| _d S )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Úaddrr	   r	   r
   r   P   s   


zWindowsPipe.__init__c                 C   s   | j  ¡  | j ¡  d| _d S r   )r0   r   r4   r   r   r	   r	   r
   r   _   s   


zWindowsPipe.closec                 C   s
   | j  ¡ S r   )r0   r   r   r	   r	   r
   r   e   s   
zWindowsPipe.filenoc                 C   s&   | j r| jrd S | j d¡ d| _ d S r   )r   r   r0   Úrecvr   r	   r	   r
   r   h   s   
zWindowsPipe.clearc                 C   s&   | j s| jrd S d| _ | j d¡ d S r   )r   r   r4   Úsendr   r	   r	   r
   r"   n   s   zWindowsPipe.setc                 C   r#   r   r$   r   r	   r	   r
   r%   t   r&   zWindowsPipe.set_foreverN)
r'   r(   r)   Ú__doc__r   r   r   r   r"   r%   r	   r	   r	   r
   r   J   s    r   c                   @   s$   e Zd Zdd„ Zdd„ Zdd„ ZdS )ÚOrPipec                 C   s   d| _ d | _|| _d S r   )r   Ú_partnerÚ_pipe)r   r   r	   r	   r
   r   z   s   
zOrPipe.__init__c                 C   ó    d| _ | jj s| j ¡  d S d S r   )r   r;   r<   r"   r   r	   r	   r
   r"      ó   ÿz
OrPipe.setc                 C   r=   r   )r   r;   r<   r   r   r	   r	   r
   r   „   r>   zOrPipe.clearN)r'   r(   r)   r   r"   r   r	   r	   r	   r
   r:   y   s    r:   c                 C   s$   t | ƒ}t | ƒ}||_||_||fS )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Úp2r	   r	   r
   Úmake_or_pipeŠ   s
   rA   )	r9   r   r   r+   r   r   r   r:   rA   r	   r	   r	   r
   Ú<module>   s   	!/