???<!-- GIF89;a -->
123123123123
.....................................................................................................................................???<!-- GIF89;a -->
123123123123
.....................................................................................................................................3
i1@                 @   s>  d Z ddlZddlZdZddlmZmZm	Z	 ddlm
Z
 ddlmZ ddlmZ ddlmZmZ dd	lmZ dd
lmZ eekredeeejdkrddlmZ eZejdkrejdkreej jjdd dk reZddlmZmZ m!Z"m#Z$ d}ddZ%d~ddZ&i Z'dd Z(ejdkr\ddlm)Z* ddlm+Z, i Z-dd Z.e.j rte(j j/dde._ nejdkrtddlm0Z* ddlm1Z1m2Z2m3Z3m4Z4m5Z5 ddlm6Z6m7Z7 dd lm8Z8 dd!d"Z9G d#d$ d$e8Z:e9e:d% G d&d' d'e8Z;e9e; G d(d) d)e8Z<e9e< G d*d+ d+e8Z=e9e= G d,d- d-e8Z>e9e> ed.ed/krLe=Z?e>Z@n0G d0d1 d1e8Z?e9e? G d2d3 d3e8Z@e9e@ G d4d5 d5e8ZAe9eA G d6d7 d7e8ZBe9eB G d8d9 d9e8ZCe1eCe1eBkreBZCed/ed:kre=ZDe>ZEn0G d;d< d<e8ZDe9eD G d=d> d>e8ZEe9eE G d?d@ d@e8ZFeF eF_GeF_He9eF G dAdB dBe8ZIeI eI_GeI_He9eI G dCdD dDe8ZJeJ eJ_GeJ_He9eJ G dEdF dFe8ZKe9eKd% G dGdH dHe8ZLeLZMe9eL G dIdJ dJe8ZNddKlmOZOmPZPmQZQ G dLdM dMe8ZRG dNdO dOe8ZSdPdQ ZTddRdSZUdTdU ZVdVdW ZWG dXdY dYeXZYG dZd[ d[eYZZejdkrG d\d] d]eYZ[dd^lm\Z\m8Z8 G d_d` d`e8Z]G dadb dbeYZ^G dcdd ddeXZ_e_eYZ`e_eZZaejdkreZdedejbZcn,ejdfkreZdgejdddh  ZcneZdZcejdkrNe_e[Zee_e^Zfejdkr,eejgjhZhneejijhZhddilmjZjmkZk ddjdkZle1e@e1eLkrje@Zme?Znn6e1e>e1eLkre>Zme=Znne1eEe1eLkreEZmeDZnddllmoZompZpmqZqmrZr e(eLeLeLemeoZse(eLeLe?emepZtdmdn Zueue:eLe:e:erZvdodp Zweue:eLe?eqZxddrdsZyyddtlmzZz W n e{k
r>   Y nX eue:eLe?ezZ|ddudvZ}ejdkrvdwdx Z~dydz Zdd{lmZmZ eIZeFZxPe;e?e=eDgD ]@Ze1edhkreZn&e1ed|kreZne1edkreZqW xPe<e@e>eEgD ]@Ze1edhkreZn&e1ed|kreZne1edkreZqW [eT  dS )z,create and manipulate C data types in Python    Nz1.1.0)Union	StructureArray)_Pointer)CFuncPtr)__version__)
RTLD_LOCALRTLD_GLOBAL)ArgumentError)calcsizezVersion number mismatchnt)FormatErrorposixdarwin.   )FUNCFLAG_CDECLFUNCFLAG_PYTHONAPIFUNCFLAG_USE_ERRNOFUNCFLAG_USE_LASTERRORc             C   s^   t | tr6|dkrt| d }t| }| }| |_|S t | trRt|  }| }|S t| dS )zcreate_string_buffer(aBytes) -> character array
    create_string_buffer(anInteger) -> character array
    create_string_buffer(aBytes, anInteger) -> character array
    N   )
isinstancebyteslenc_charvalueint	TypeError)initsizebuftypebuf r"   '/usr/lib64/python3.6/ctypes/__init__.pycreate_string_buffer/   s    

r$   c             C   s
   t | |S )N)r$   )r   r   r"   r"   r#   c_bufferA   s    r%   c                s   t |jddrtO |jddr,tO |r@td|j  yt f S  tk
r   G  fdddt}|t f< |S X dS )a  CFUNCTYPE(restype, *argtypes,
                 use_errno=False, use_last_error=False) -> function prototype.

    restype: the result type
    argtypes: a sequence specifying the argument types

    The function prototype can be called in different ways to create a
    callable object:

    prototype(integer address) -> foreign function
    prototype(callable) -> create and return a C callable function from callable
    prototype(integer index, method name[, paramflags]) -> foreign function calling a COM method
    prototype((ordinal number, dll object)[, paramflags]) -> foreign function exported by ordinal
    prototype((function name, dll object)[, paramflags]) -> foreign function exported by name
    	use_errnoFuse_last_errorz!unexpected keyword argument(s) %sc                   s   e Zd Z ZZZdS )z CFUNCTYPE.<locals>.CFunctionTypeN)__name__
__module____qualname__
_argtypes_	_restype__flags_r"   )argtypesflagsrestyper"   r#   CFunctionTypec   s   r1   N)	_FUNCFLAG_CDECLpop_FUNCFLAG_USE_ERRNO_FUNCFLAG_USE_LASTERROR
ValueErrorkeys_c_functype_cacheKeyError	_CFuncPtr)r0   r.   kwr1   r"   )r.   r/   r0   r#   	CFUNCTYPEI   s    r<   )LoadLibrary)FUNCFLAG_STDCALLc                s   t |jddrtO |jddr,tO |r@td|j  yt f S  tk
r   G  fdddt}|t f< |S X d S )Nr&   Fr'   z!unexpected keyword argument(s) %sc                   s   e Zd Z ZZZdS )z$WINFUNCTYPE.<locals>.WinFunctionTypeN)r(   r)   r*   r+   r,   r-   r"   )r.   r/   r0   r"   r#   WinFunctionType{   s   r?   )	_FUNCFLAG_STDCALLr3   r4   r5   r6   r7   _win_functype_cacher9   r:   )r0   r.   r;   r?   r"   )r.   r/   r0   r#   WINFUNCTYPEo   s    rB   )dlopen)sizeofbyref	addressof	alignmentresize)	get_errno	set_errno)_SimpleCDatac             C   sJ   ddl m} |d kr| j}t| || }}||krFtd| ||f d S )Nr   )r   z"sizeof(%s) wrong: %d instead of %d)structr   _type_rD   SystemError)typtypecoder   ZactualZrequiredr"   r"   r#   _check_size   s    rQ   c                   s    e Zd ZdZ fddZ  ZS )	py_objectOc                s.   y
t  j S  tk
r(   dt| j S X d S )Nz
%s(<NULL>))super__repr__r6   typer(   )self)	__class__r"   r#   rU      s    
zpy_object.__repr__)r(   r)   r*   rM   rU   __classcell__r"   r"   )rX   r#   rR      s   rR   Pc               @   s   e Zd ZdZdS )c_shorthN)r(   r)   r*   rM   r"   r"   r"   r#   r[      s   r[   c               @   s   e Zd ZdZdS )c_ushortHN)r(   r)   r*   rM   r"   r"   r"   r#   r]      s   r]   c               @   s   e Zd ZdZdS )c_longlN)r(   r)   r*   rM   r"   r"   r"   r#   r_      s   r_   c               @   s   e Zd ZdZdS )c_ulongLN)r(   r)   r*   rM   r"   r"   r"   r#   ra      s   ra   ir`   c               @   s   e Zd ZdZdS )c_intrc   N)r(   r)   r*   rM   r"   r"   r"   r#   rd      s   rd   c               @   s   e Zd ZdZdS )c_uintIN)r(   r)   r*   rM   r"   r"   r"   r#   re      s   re   c               @   s   e Zd ZdZdS )c_floatfN)r(   r)   r*   rM   r"   r"   r"   r#   rg      s   rg   c               @   s   e Zd ZdZdS )c_doubledN)r(   r)   r*   rM   r"   r"   r"   r#   ri      s   ri   c               @   s   e Zd ZdZdS )c_longdoublegN)r(   r)   r*   rM   r"   r"   r"   r#   rk      s   rk   qc               @   s   e Zd ZdZdS )
c_longlongrm   N)r(   r)   r*   rM   r"   r"   r"   r#   rn      s   rn   c               @   s   e Zd ZdZdS )c_ulonglongQN)r(   r)   r*   rM   r"   r"   r"   r#   ro      s   ro   c               @   s   e Zd ZdZdS )c_ubyteBN)r(   r)   r*   rM   r"   r"   r"   r#   rq      s   rq   c               @   s   e Zd ZdZdS )c_bytebN)r(   r)   r*   rM   r"   r"   r"   r#   rs      s   rs   c               @   s   e Zd ZdZdS )r   cN)r(   r)   r*   rM   r"   r"   r"   r#   r      s   r   c               @   s   e Zd ZdZdd ZdS )c_char_pzc             C   s   d| j jtj| jf S )Nz%s(%s))rX   r(   c_void_pfrom_bufferr   )rW   r"   r"   r#   rU      s    zc_char_p.__repr__N)r(   r)   r*   rM   rU   r"   r"   r"   r#   rv      s   rv   c               @   s   e Zd ZdZdS )rx   rZ   N)r(   r)   r*   rM   r"   r"   r"   r#   rx      s   rx   c               @   s   e Zd ZdZdS )c_bool?N)r(   r)   r*   rM   r"   r"   r"   r#   rz      s   rz   )POINTERpointer_pointer_type_cachec               @   s   e Zd ZdZdd ZdS )	c_wchar_pZc             C   s   d| j jtj| jf S )Nz%s(%s))rX   r(   rx   ry   r   )rW   r"   r"   r#   rU      s    zc_wchar_p.__repr__N)r(   r)   r*   rM   rU   r"   r"   r"   r#   r      s   r   c               @   s   e Zd ZdZdS )c_wcharuN)r(   r)   r*   rM   r"   r"   r"   r#   r      s   r   c               C   sF   t j  tj  tjdkr"tj  tjtt	_t
jtt_tt d < d S )Nr   )r~   clearr8   _osnamerA   r   Z
from_paramr|   r   rv   r   rx   r"   r"   r"   r#   _reset_cache  s    
r   c             C   s^   t | tr6|dkrt| d }t| }| }| |_|S t | trRt|  }| }|S t| dS )zcreate_unicode_buffer(aString) -> character array
    create_unicode_buffer(anInteger) -> character array
    create_unicode_buffer(aString, anInteger) -> character array
    Nr   )r   strr   r   r   r   r   )r   r   r    r!   r"   r"   r#   create_unicode_buffer  s    

r   c             C   sL   t j|d d k	rtdt| t kr,td| j| | t |< t t| = d S )Nz%This type already exists in the cachezWhat's this???)r~   getRuntimeErroridZset_type)r}   clsr"   r"   r#   SetPointerType"  s    
r   c             C   s   | | S )Nr"   )rO   r   r"   r"   r#   ARRAY,  s    r   c               @   sN   e Zd ZdZeZeZdZdZ	dZ
edddfddZdd	 Zd
d Zdd ZdS )CDLLa  An instance of this class represents a loaded dll/shared
    library, exporting functions using the standard C calling
    convention (named 'cdecl' on Windows).

    The exported functions can be accessed as attributes, or by
    indexing with the function name.  Examples:

    <obj>.qsort -> callable object
    <obj>['qsort'] -> callable object

    Calling the functions releases the Python GIL during the call and
    reacquires it afterwards.
    z<uninitialized>r   NFc                sb   |_ j |r tO  |r$ tO  G  fdddt}|_|d krXtj |_n|_d S )Nc                   s   e Zd Z ZjZdS )zCDLL.__init__.<locals>._FuncPtrN)r(   r)   r*   r-   _func_restype_r,   r"   )r/   rW   r"   r#   _FuncPtrQ  s   r   )_name_func_flags_r4   r5   r:   r   _dlopen_handle)rW   r   modeZhandler&   r'   r   r"   )r/   rW   r#   __init__G  s    zCDLL.__init__c             C   s8   d| j j| j| jtjd d @ t| tjd d @ f S )Nz<%s '%s', handle %x at %#x>   r   )rX   r(   r   r   _sysmaxsizer   )rW   r"   r"   r#   rU   [  s    
zCDLL.__repr__c             C   s6   |j dr|jdrt|| j|}t| || |S )N__)
startswithendswithAttributeError__getitem__setattr)rW   r   funcr"   r"   r#   __getattr__a  s
    
zCDLL.__getattr__c             C   s"   | j || f}t|ts||_|S )N)r   r   r   r(   )rW   Zname_or_ordinalr   r"   r"   r#   r   h  s    
zCDLL.__getitem__)r(   r)   r*   __doc__r2   r   rd   r   r   r   r   DEFAULT_MODEr   rU   r   r   r"   r"   r"   r#   r   2  s   r   c               @   s   e Zd ZdZeeB ZdS )PyDLLzThis class represents the Python library itself.  It allows
    accessing Python API functions.  The GIL is not released, and
    Python exceptions are handled correctly.
    N)r(   r)   r*   r   r2   _FUNCFLAG_PYTHONAPIr   r"   r"   r"   r#   r   n  s   r   c               @   s   e Zd ZdZeZdS )WinDLLznThis class represents a dll exporting functions using the
        Windows stdcall calling convention.
        N)r(   r)   r*   r   r@   r   r"   r"   r"   r#   r   w  s   r   )_check_HRESULTrK   c               @   s   e Zd ZdZeZdS )HRESULTr`   N)r(   r)   r*   rM   r   Z_check_retval_r"   r"   r"   r#   r     s   
r   c               @   s   e Zd ZdZeZeZdS )OleDLLzThis class represents a dll exporting functions using the
        Windows stdcall calling convention, and returning HRESULT.
        HRESULT error values are automatically raised as OSError
        exceptions.
        N)r(   r)   r*   r   r@   r   r   r   r"   r"   r"   r#   r     s   r   c               @   s,   e Zd Zdd Zdd Zdd Zdd Zd	S )
LibraryLoaderc             C   s
   || _ d S )N)_dlltype)rW   Zdlltyper"   r"   r#   r     s    zLibraryLoader.__init__c             C   s.   |d dkrt || j|}t| || |S )Nr   _)r   r   r   )rW   r   Zdllr"   r"   r#   r     s
    
zLibraryLoader.__getattr__c             C   s
   t | |S )N)getattr)rW   r   r"   r"   r#   r     s    zLibraryLoader.__getitem__c             C   s
   | j |S )N)r   )rW   r   r"   r"   r#   r=     s    zLibraryLoader.LoadLibraryN)r(   r)   r*   r   r   r   r=   r"   r"   r"   r#   r     s   r   z
python dllcygwinzlibpython%d.%d.dllr   )get_last_errorset_last_errorc             C   s0   | d krt  } |d kr"t| j }td |d | S )N)GetLastErrorr   stripOSError)codeZdescrr"   r"   r#   WinError  s
    r   )_memmove_addr_memset_addr_string_at_addr
_cast_addrc                s   G  fdddt }|S )Nc                   s   e Zd Z ZZeeB ZdS )z!PYFUNCTYPE.<locals>.CFunctionTypeN)r(   r)   r*   r+   r,   r2   r   r-   r"   )r.   r0   r"   r#   r1     s   r1   )r:   )r0   r.   r1   r"   )r.   r0   r#   
PYFUNCTYPE  s    r   c             C   s   t | | |S )N)_cast)objrO   r"   r"   r#   cast  s    r   r   c             C   s
   t | |S )zAstring_at(addr[, size]) -> string

    Return the string at addr.)
_string_at)ptrr   r"   r"   r#   	string_at  s    r   )_wstring_at_addrc             C   s
   t | |S )zFwstring_at(addr[, size]) -> string

        Return the string at addr.)_wstring_at)r   r   r"   r"   r#   
wstring_at  s    r   c             C   s@   yt dt t dg}W n tk
r,   dS X |j| ||S d S )Nzcomtypes.server.inprocserver*ii)
__import__globalslocalsImportErrorDllGetClassObject)ZrclsidZriidZppvccomr"   r"   r#   r     s
    r   c              C   s6   yt dt t dg} W n tk
r,   dS X | j S )Nzcomtypes.server.inprocserverr   r   )r   r   r   r   DllCanUnloadNow)r   r"   r"   r#   r     s
    r   )BigEndianStructureLittleEndianStructure   )N)N)N)N)NN)r   r   )r   )r   osr   sysr   r   Z_ctypesr   r   r   r   r   r:   Z_ctypes_versionr   r	   r
   rL   r   Z	_calcsize	Exceptionr   r   r   platformr   unamereleasesplitr   r2   r   r   r   r4   r   r5   r$   r%   r8   r<   r=   r   r>   r@   rA   rB   replacerC   rD   rE   rF   rG   rH   rI   rJ   rK   rQ   rR   r[   r]   r_   ra   rd   re   rg   ri   rk   rn   ro   rq   Z__ctype_le__Z__ctype_be__rs   r   rv   rx   Zc_voidprz   r|   r}   r~   r   r   r   r   r   r   objectr   r   r   r   r   r   r   ZcdllZpydllZ	dllhandleZ	pythonapiversion_infoZwindllZoledllZkernel32r   Zcoredllr   r   r   Zc_size_tZ	c_ssize_tr   r   r   r   ZmemmoveZmemsetr   r   r   r   r   r   r   r   r   r   r   Zctypes._endianr   r   Zc_int8Zc_uint8ZkindZc_int16Zc_int32Zc_int64Zc_uint16Zc_uint32Zc_uint64r"   r"   r"   r#   <module>   s8  


!




<	



   
   
