
    Ϫf+                         d Z ddlZddlZddlmZ ddlZddlmZmZ ddl	m
Z
mZmZmZmZ ddlmZ  ee
       G d d             Z eeee       G d	 d
ej$                               Zy)zM
Windows-specific implementation of the L{twisted.internet.stdio} interface.
    N)implementer)_pollingfilemain)IAddress	IConsumerIHalfCloseableProtocolIPushProducer
ITransport)Failurec                       e Zd Zy)Win32PipeAddressN)__name__
__module____qualname__     >/usr/lib/python3/dist-packages/twisted/internet/_win32stdio.pyr   r      s    r   r   c                   t    e Zd ZdZdZddZd Zd Zd ZdZ	d Z
d	 Zd
 Zd Zd Zd Zd Zd Zd Zd Zd Zy)
StandardIOFNc                    |ddl m} t        ddd      D ]&  }t        j                  |t
        j                         ( t        j                  j                  | |       || _
        t        j                  t        j                        }t        j                  t        j                        }t        j                  || j                   | j"                        | _        t        j&                  || j(                        | _        | j-                  | j$                         | j-                  | j*                         | j                  j/                  |        y)z
        Start talking to standard IO with the given protocol.

        Also, put it stdin/stdout/stderr into binary mode.
        Nr   )reactor      )twisted.internetr   rangemsvcrtsetmodeosO_BINARYr   _PollingTimer__init__protowin32apiGetStdHandleSTD_INPUT_HANDLESTD_OUTPUT_HANDLE_PollableReadPipedataReceivedreadConnectionLoststdin_PollableWritePipewriteConnectionLoststdout_addPollableResourcemakeConnection)selfr"   r   stdfdhstdinhstdouts         r   r!   zStandardIO.__init__$   s     ?01a^ 	/ENN5"++.	/ 	""++D':
&&x'@'@A''(B(BC!33D%%t'>'>

 #55gt?W?WX!!$**-!!$++.

!!$'r   c                 :    | j                   j                  |       y N)r"   r(   r0   datas     r   r(   zStandardIO.dataReceivedA   s    

%r   c                     t        j                  | j                        r| j                  j                          | j	                          y r5   )r   
providedByr"   r)   checkConnLostr0   s    r   r)   zStandardIO.readConnectionLostD   s0    !,,TZZ8JJ))+r   c                     t        j                  | j                        r| j                  j                          | j	                          y r5   )r   r9   r"   r,   r:   r;   s    r   r,   zStandardIO.writeConnectionLostI   s0    !,,TZZ8JJ**,r   r   c                     | xj                   dz  c_         | j                   dk\  rAd| _        d| _        | j                  j	                  t        t        j                               y y )Nr   r   T)	connsLostdisconnectingdisconnectedr"   connectionLostr   r   CONNECTION_DONEr;   s    r   r:   zStandardIO.checkConnLostP   sN    !>>Q!%D $DJJ%%gd.B.B&CD r   c                 :    | j                   j                  |       y r5   )r-   writer6   s     r   rD   zStandardIO.writeY   s    $r   c                 X    | j                   j                  dj                  |             y )Nr   )r-   rD   join)r0   seqs     r   writeSequencezStandardIO.writeSequence\   s    #((3-(r   c                 z    d| _         | j                  j                          | j                  j                          y )NT)r?   r*   closer-   r;   s    r   loseConnectionzStandardIO.loseConnection_   s*    !

r   c                     t               S r5   r   r;   s    r   getPeerzStandardIO.getPeerd       !!r   c                     t               S r5   rM   r;   s    r   getHostzStandardIO.getHostg   rO   r   c                 :    | j                   j                  ||      S r5   )r-   registerProducer)r0   producer	streamings      r   rS   zStandardIO.registerProducerl   s    {{++Hi@@r   c                 6    | j                   j                         S r5   )r-   unregisterProducerr;   s    r   rW   zStandardIO.unregisterProducero   s    {{--//r   c                 8    | j                   j                          y r5   )r*   stopProducingr;   s    r   rY   zStandardIO.stopProducingv   s    

  "r   c                 8    | j                   j                          y r5   )r*   pauseProducingr;   s    r   r[   zStandardIO.pauseProducing{   s    

!!#r   c                 8    | j                   j                          y r5   )r*   resumeProducingr;   s    r   r]   zStandardIO.resumeProducing~   s    

""$r   r5   )r   r   r   r?   r@   r!   r(   r)   r,   r>   r:   rD   rH   rK   rN   rQ   rS   rW   rY   r[   r]   r   r   r   r   r      s`    ML(:&

 IE )
""
A0#
$%r   r   )__doc__r   r   zope.interfacer   r#   r   r   r   twisted.internet.interfacesr   r   r   r	   r
   twisted.python.failurer   r   r    r   r   r   r   <module>rb      su   
  	 &  /  + X	 	 	 ZM2_%++ _% 3_%r   