4C/d dZddlZddlZddlZdZddlm Z m Z m Z ddlm Z ddlm ZddlmZddlmZmZdd lmZdd lmZeekr ed eeejd krdd lmZeZejdkrGejdkr<eejjdddkreZddlmZ m!Z"m#Z$m%Z&dodZ'e'Z(iZ)dZ*ejd kr9ddlm+Z,ddlm-Z.iZ/dZ0e0jr e*j1dde0_nejdkrddlm2Z,ddlm3Z3m4Z4m5Z5m6Z6m7Z7ddlm8Z8m9Z9ddlm:Z:dodZ;Gdd e:Z<e;ee;e>Gd&d'e:Z?e;e?Gd(d)e:Z@e;e@ed*ed+kre?ZAe@ZBn2Gd,d-e:ZAe;eAGd.d/e:ZBe;eBGd0d1e:ZCe;eCGd2d3e:ZDe;eDGd4d5e:ZEe3eEe3eDkreDZEed+ed6kre?ZFe@ZGn2Gd7d8e:ZFe;eFGd9d:e:ZGe;eGGd;de:ZKeKxeK_IeK_Je;eKGd?d@e:ZLeLxeL_IeL_Je;eLGdAdBe:ZMe;eMd!GdCdDe:ZNeNZOe;eNGdEdFe:ZPddGlmQZQmRZRmSZSGdHdIe:ZTGdJdKe:ZUdLZVdodMZWdNZXdOZYGdPdQeZZ[GdRdSe[Z\ejd kr2GdTdUe[Z]ddVlm^Z^m:Z:GdWdXe:Z_GdYdZe[Z`Gd[d\eZZaeae[Zbeae\Zcejd kre\d]dejdZen2ejd^kre\d_ejfdd`zZen e\dZeejd kr.eae]Zgeae`ZhegjijjZjddalmkZkmlZldpdbZme3eBe3eNkreBZneAZon9e3e@e3eNkre@Zne?Zone3eGe3eNkreGZneFZoddclmpZpmqZqmrZrmsZse*eNeNeNenepZte*eNeNeAeneqZuddZveveeBe@eGfD]7Ze3ed`kreZe3ednkreZ&e3edkreZ8[eVdS)rz,create and manipulate C data types in PythonNz1.1.0)Union StructureArray)_Pointer)CFuncPtr) __version__) RTLD_LOCAL RTLD_GLOBAL) ArgumentErrorcalcsizezVersion number mismatchnt) FormatErrorposixdarwin.)FUNCFLAG_CDECLFUNCFLAG_PYTHONAPIFUNCFLAG_USE_ERRNOFUNCFLAG_USE_LASTERRORcZt|trG|t|dz}tjd||t |z}|}||_|St|tr,tjdd|t |z}|}|St|)zcreate_string_buffer(aBytes) -> character array create_string_buffer(anInteger) -> character array create_string_buffer(aBytes, anInteger) -> character array Nzctypes.create_string_buffer) isinstancebyteslen_sysauditc_charvalueint TypeErrorinitsizebuftypebufs 6/opt/alt/python311/lib64/python3.11/ctypes/__init__.pycreate_string_bufferr)0s $  <t99Q;D 0$===4-gii  D#   0$===4-gii D//cpt|ddr tz|ddr tz|r$t d|z t fS#t$rYnwxYwGfddt}|t f<|S)aCFUNCTYPE(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_errnoFuse_last_error!unexpected keyword argument(s) %sceZdZZZZdS) CFUNCTYPE..CFunctionTypeN__name__ __module__ __qualname__ _argtypes_ _restype__flags_argtypesflagsrestypesr( CFunctionTyper0es  r*r<) _FUNCFLAG_CDECLpop_FUNCFLAG_USE_ERRNO_FUNCFLAG_USE_LASTERROR ValueErrorkeys_c_functype_cacheKeyError _CFuncPtr)r;r9kwr<r:s`` @r( CFUNCTYPErGHs E vvk5!!% $$ vv&&) (( J.WinFunctionTypeNr1r8sr(WinFunctionTyperMs!JIGGGr*rN) _FUNCFLAG_STDCALLr>r?r@rArB_win_functype_cacherDrE)r;r9rFrNr:s`` @r( WINFUNCTYPErQqs! 66+u % % ) ( (E 66"E * * - , ,E  N@27799LMM M &5'AB B    D          i   ;JWh67rHrGrQ)dlopen)sizeofbyref addressof alignmentresize) get_errno set_errno) _SimpleCDatacddlm}||j}t|||}}||krt d|||fzdS)Nrr z"sizeof(%s) wrong: %d instead of %d)structr _type_rS SystemError)typtypecoder actualrequireds r( _check_sizercss :c{{HHX$6$6HF >1233 3r*c"eZdZdZfdZxZS) py_objectOc tS#t$rdt|jzcYSwxYw)Nz %s())super__repr__rAtyper2)self __class__s r(rizpy_object.__repr__sS 677##%% % 6 6 6$t**"55 5 5 5 6s#!AA)r2r3r4r]ri __classcell__)rls@r(reres= F666666666r*rePceZdZdZdS)c_shorthNr2r3r4r]r*r(rprp FFFr*rpceZdZdZdS)c_ushortHNrrrsr*r(rvrvrtr*rvceZdZdZdS)c_longlNrrrsr*r(ryryrtr*ryceZdZdZdS)c_ulongLNrrrsr*r(r|r|rtr*r|irzceZdZdZdS)c_intr~Nrrrsr*r(rrr*rceZdZdZdS)c_uintINrrrsr*r(rrrr*rceZdZdZdS)c_floatfNrrrsr*r(rrrtr*rceZdZdZdS)c_doubledNrrrsr*r(rrrtr*rceZdZdZdS) c_longdoublegNrrrsr*r(rrrtr*rqceZdZdZdS) c_longlongrNrrrsr*r(rrrr*rceZdZdZdS) c_ulonglongQNrrrsr*r(rrrr*rceZdZdZdS)c_ubyteBNrrrsr*r(rrrtr*rceZdZdZdS)c_bytebNrrrsr*r(rrrtr*rceZdZdZdS)rcNrrrsr*r(rrrtr*rceZdZdZdZdS)c_char_pzc`|jjdt|jdSN()rlr2c_void_p from_bufferr rks r(rizc_char_p.__repr__/>222H4H4H4N4N4T4T4TUUr*Nr2r3r4r]rirsr*r(rr- FVVVVVr*rceZdZdZdS)rrnNrrrsr*r(rrrtr*rceZdZdZdS)c_bool?Nrrrsr*r(rrrtr*r)POINTERpointer_pointer_type_cacheceZdZdZdZdS) c_wchar_pZc`|jjdt|jdSrrrs r(rizc_wchar_p.__repr__rr*Nrrsr*r(rrrr*rceZdZdZdS)c_wcharuNrrrsr*r(rrrtr*rcZtjttjdkrt t jtt_tjtt_ttd<dS)Nr) rclearrC_osnamerPr from_paramrrrrrrsr*r( _reset_cachersw x4!!###"+"6GG!)!4GFOO (r*ct|tr||Gttdkrt d|Ddz}nt |dz}t jd||t|z}|}||_|St|tr,t jdd|t|z}|}|St|)zcreate_unicode_buffer(aString) -> character array create_unicode_buffer(anInteger) -> character array create_unicode_buffer(aString, anInteger) -> character array Nc3DK|]}t|dkrdndVdS)irrN)ord).0rs r( z(create_unicode_buffer..s4EE1A11QEEEEEEr*rzctypes.create_unicode_buffer) rstrrSrsumrrrr r!r"r#s r(create_unicode_bufferrs $ <g!##EEEEEEEI4yy1} 14>>>D.gii  D#   14>>>D.gii D//r*ctj|dtdt|tvrtd|j||t|<tt|=dS)Nz%This type already exists in the cachezWhat's this???)rget RuntimeErroridset_type)rclss r(SetPointerTyper1swsD))5BCCC '{{---+,,,GS&BwKK(((r*c ||zSNrs)r_rs r(ARRAYr;s 9r*cJeZdZdZeZeZdZdZ dZ e ddddfdZ dZ dZd ZdS) CDLLaAn 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: .qsort -> callable object ['qsort'] -> callable object Calling the functions releases the Python GIL during the call and reacquires it afterwards. zrNFc* |_j |r tz |r tz tjdr8 |r5|dr d|vr|tj tj zz}tj dkrA||}n._FuncPtrN)r2r3r4r7_func_restype_r6)r:rksr(_FuncPtrrrsG+IIIr*r)_name _func_flags_r?r@rplatform startswithendswithr RTLD_MEMBERRTLD_NOWrr!_LOAD_LIBRARY_SEARCH_DEFAULT_DIRS_getfullpathname!_LOAD_LIBRARY_SEARCH_DLL_LOAD_DIRrEr_dlopen_handle) rkrmodehandler,r-winmoderrr:s ` @r(__init__z CDLL.__init__VsY !  ) ( (E  - , ,E = # #E * * ;   ; c** ;u}}#/CL8: 8t  " ;$;;$$,,!#!4!4TZ!@!@DJB@@D , , , , , , , ,y , , ,! >"4:t44DLLL!DLLLr*cd|jj|j|jtjdzdzzt |tjdzdzzfzS)Nz<%s '%s', handle %x at %#x>rr)rlr2rrrmaxsizerrs r(riz CDLL.__repr__|sN,'a!!344DLNQ./11 1r*c|dr$|drt|||}t ||||S)N__)rrAttributeError __getitem__setattr)rkrfuncs r( __getattr__zCDLL.__getattr__sa ??4  'T]]4%8%8 ' && &%%dD!!! r*cl|||f}t|ts||_|Sr)rrr!r2)rkname_or_ordinalrs r(rzCDLL.__getitem__s6}}ot455/3// ,+DM r*)r2r3r4__doc__r=rrrrrr DEFAULT_MODErrirrrsr*r(rrAs  #LN EGH".t %$"$"$"$"L111 r*rceZdZdZeezZdS)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)r2r3r4rr=_FUNCFLAG_PYTHONAPIrrsr*r(rrs%#%88LLLr*rceZdZdZeZdS)WinDLLznThis class represents a dll exporting functions using the Windows stdcall calling convention. N)r2r3r4rrOrrsr*r(rrs  ) r*r)_check_HRESULTrZceZdZdZeZdS)HRESULTrzN)r2r3r4r]r_check_retval_rsr*r(rrs(r*rceZdZdZeZeZdS)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)r2r3r4rrOrrrrsr*r(rrs$  )  r*rcFeZdZdZdZdZdZeej Z dS) LibraryLoaderc||_dSr_dlltype)rkdlltypes r(rzLibraryLoader.__init__s  r*c|ddkrt|||}t||||S)Nr_)rrr)rkrdlls r(rzLibraryLoader.__getattr__sE 7c>> && &mmD!!dC    r*c"t||Sr)getattrrkrs r(rzLibraryLoader.__getitem__stT"""r*c,||Srrrs r(rIzLibraryLoader.LoadLibrarys}}T"""r*N) r2r3r4rrrrI classmethod_types GenericAlias__class_getitem__rsr*r(rrsa   ######$ F$788r*rz python dllcygwinzlibpython%d.%d.dllr)get_last_errorset_last_errorc|t}|!t|}td|d|Sr) GetLastErrorrstripOSError)codedescrs r(WinErrorrsB <>>D =%%++--EtUD$///r*) _memmove_addr _memset_addr_string_at_addr _cast_addrc6Gfddt}|S)Nc"eZdZZZeezZdS)!PYFUNCTYPE..CFunctionTypeN)r2r3r4r5r6r=rr7)r9r;sr(r<r$s$  !$77r*r<)rE)r;r9r<s`` r( PYFUNCTYPEr%sE88888888 888 r*c$t|||Sr)_cast)objr_s r(castr)s c3  r*c"t||S)zAstring_at(addr[, size]) -> string Return the string at addr.) _string_atptrr%s r( string_atr/s c4  r*)_wstring_at_addrc"t||S)zFwstring_at(addr[, size]) -> string Return the string at addr.) _wstring_atr-s r( wstring_atr3s3%%%r*c tdttdg}||||S#t$rYdSwxYw)Ncomtypes.server.inprocserver*i) __import__globalslocalsDllGetClassObject ImportError)rclsidriidppvccoms r(r:r:se =rmsK 22 ++++++++++))))))222222++++++++!!!!!!((((((/!! )-{O L LL8t###### 8w4=H44  s939;;  $ $S ) )! ,--11" 777777777777* """H8t......======*T'/77 ]SS X))))))??????????????((((((((  3 3 3 366666 666 Isl G| H\ Fl G 9S>>YYs^^## E FF KKl G| H< 6,66(++++L 9S>>YYs^^##JKK\K l K l.55w+ G\,22f) F\,22f) FVVVVV|VVV Hc|  H\:999999999VVVVV VVV l ) ) )<))) LLLLL6LLL\99999D9998t))))))))54444444 ( ( ( ( (, ( ( (!!!!!!!!99999F999&}T e8tlD$.99II ]h*T->rr-BBCCIId I8t ]6 " "F ]6 " "F?/L666666660000 6&>>VVH%%%%HII VG__x((((HII VKFF8,,,,HIMLLLLLLLLLLL <))Hh( ; ;M J J 88Xuh 7 7 E E > 9h 9==jII   4ZZ 8U 3 3O D D !!!! &((((((9**Y%889IJJK&&&&&    D 8t===&&&EDDDDDDD<<<<<<<<   eVZ 0++D vd||qD''   dGG   dG vw 4,,D vd||qT((   tHH   tH s4VVV