lfǬlddlmZddlmZmZddlmZmZ ddlmZ n#e $rddl Z YnwxYwddl Z ddl Z ddl Z e jdkrddlZnddlZejZn #e $rdZYnwxYwdZd Ze jd e je jzZe jd e je jzZe jd e jZe jd Ze jdZe jdZe jdZdae jde j Z!e jdZ"e jdZ#e jdZ$e jdZ%e jdZ&e jdZ'e jdZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/d Z0d!Z1Gd"d#e2Z3dS)$)model) COMMON_TYPESresolve_common_type)FFIError CDefError) _pycparserN)cddl}ddl}dSNr )pycparser.yacctabpycparser.lextab) pycparsers n/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib64/python3.11/site-packages/cffi/cparser.py%_workaround_for_static_import_findersrs"zz/\*.*?\*/|//([^\n\\]|\\.)*?$z?^\s*#\s*define\s+([A-Za-z_][A-Za-z_0-9]*)\b((?:[^\n\\]|\\.)*?)$z^[ \t]*#[ \t]*(?:line|\d+)\b.*$z=\s*\.\.\.\s*[,}]|\.\.\.\s*\}z__dotdotdot\d+__$z\[\s*\.\.\.\s*\]z\w+|\Sz-?0?x?[0-9a-f]+[lu]*$z\b(__stdcall|WINAPI)\bz[(]\s*(__stdcall|WINAPI)\bz \b__cdecl\bz9\bextern\s*"(Python|Python\s*\+\s*C|C\s*\+\s*Python)"\s*.z'[*]\s*((const|volatile|restrict)\b\s*)+z3(\b(int|long|short|signed|unsigned|char)\s*)+\.\.\.z\b(double|float)\s*\.\.\.cDttjatSN) _parser_cacherCParserrr _get_parserr2s!)++ rcg} t|}|sn,||d||dd}|||}|d|r|d|dz }d}|}|t|krJ||}|dkr|dz }n|dkr |dkrn)|dz}n |dvr|dkrn|dz }|t|kJ||||z||dz}J||d|S) NT()*r rz,;=) _r_star_const_spacesearchappendstartgroupend startswithlenjoin)csourcepartsmatchclosingendposlevelics r_workaround_for_old_pycparserr/8s E<#**733   W^ekkmm^,--- SS7 U[[]]###   c6 * * . LL   w#~w #g,, ACxx cA:: eA:: FA#g,,&(#g- ;3<6 LL 775>>rcg} t|}|sn|dz }||d|d|dvr|dn|d||dkr|d|}|dkrtd |d|dz|dkrtd |||dz|||dzd}nX|d |}|dkrtd ||||dz||dzd}|d ||d |S)NTrCz(void __cffi_extern_python_plus_c_start; z!void __cffi_extern_python_start; {}r z!'extern "Python" {': no '}' foundz7cannot use { } inside a block 'extern "Python" { ... }';z'extern "Python": no ';' foundz void __cffi_extern_python_stop;r) _r_extern_pythonrr#r r!r"findrNotImplementedErrorr&)r'r(r)r+r* semicolons r_preprocess_extern_pythonr9bs E9 ''00  q  W^ekkmm^,--- %++a.. LLC D D D D LL< = = = 6?c ! !ll3//G{{ EFFF||C!W55::)+HIII LL'!12 3 3 3gaijj)GG S&11I1}} BCCC LL ! !34 5 5 5ikll+G 7888=9B LL 775>>rcd|vrdS|D]I}d|vrC|dsddl}|ddSJdS)N"#r zString literal found in cdef() or type source. String literals are ignored here, but you should remove them anyway because some character sequences confuse pre-parsing.) splitlineslstripr$warningswarn)r'liner?s r_warn_for_string_literalrBs '""$$ $;;t{{}}77<<; OOO MM1 2 2 2 EErc\|js$ddl}|d|jddSdS)Nr zGlobal variable 'z_' in cdef(): for consistency with C it should have a storage class specifier (usually 'extern'))storager?r@name)declr?s r/_warn_for_non_extern_non_static_global_variablerGsO <; .2iii: ; ; ; ; ;;;rcPgfd}t||}|fS)Nczt}|d|zS)Nz#line@%d)r%r r")mr-line_directivess rreplacez(_remove_line_directives..replaces6  qwwyy)))A~r_r_line_directivesub)r'rLrKs @r_remove_line_directivesrPsE O ##GW55G O ##rcDfd}t||S)Nc|}|dstdt|ddS)Nz#line@zBunexpected #line directive (should have been processed and removed)r"r$AssertionErrorint)rJsrKs rrLz*_put_back_line_directives..replacesY GGII||H%% L "KLL Ls1QRR5zz**rrM)r'rKrLs ` r_put_back_line_directivesrWs4+++++  ' 2 22rc8t|\}}d}t||}i}t|D]F}|\}}|dd}|||<Gtd|}tj dkrt|}td|}td|}td|}t|}t|t d|}t#t$|}t't)|D]\}}|} || d krM|d | |} | | ksJd |d| ||| d zdfz}r|| | d zd ksJd |d| ||| d zdfz}t0d|}t2d|}|d d}t5||}||fS)Nc\d|ddzzS)N  )r"count)rJs rreplace_keeping_newlinesz-_preprocess..replace_keeping_newliness&QWWYY__T**T111rz\ rz2.14z volatile volatile const(z volatile volatile const rZz[__dotdotdotarray__]=...z%s,__dotdotdot%d__ %sr z%s __dotdotdot%d__ %sz __dotdotdotint__ z __dotdotdotfloat__ z __dotdotdot__ )rP _r_commentrO _r_definefinditergroupsrLstripr __version__r/ _r_stdcall2 _r_stdcall1_r_cdeclr9rB_r_partial_arraylist_r_partial_enum enumeratereversedr!r6r#_r_int_dotdotdot_r_float_dotdotdotrW) r'rKr]macrosr) macroname macrovaluematchesnumberpp2s r _preprocessrws 7w??G_222nn5w??G F##G,,'' %  :''3399;; &ymmB((Gv%%/88oo97CCGoo97CCGll3((G(00GW%%%""#97CCG?++G4455G"8G#4#455 @ @  KKMM 1:  eQ 44B6666-!f18A1AAGG1QqS5>U****-!f1811@@GG""#7AAG $$%;WEEGooe%677G'AAG F?rctt}|d|d|d|d|dt}d}d}d}t|D]}||vr|dkr/|r,||||d}nq|dkrd }d}nf|dkr|d z }nZ|dkr|d z}nN|dkr3|r0|dkr*||||n|||}|S) Nr4,rrtypedefFr rTr)setradd_r_wordsfindalldiscard)r'look_for_words words_used is_typedefparen previous_wordwords r_common_type_namesrs &&Nssssy!!!JJ EM  )) > ! !s{{'&&}555"**=999!&J""!   :%1**&&}555"**=999t$$$ rceZdZdZdZdZdZ ddZdZd Z d Z d Z d Z d Z dZdZd dZdZd!dZ d"dZd!dZdZd#dZdZd$dZdZdZdZdZdZdS)%Parserci|_t|_d|_t j|_i|_i|_g|_ d|_ dSr ) _declarationsr{_included_declarations_anonymous_counterweakrefWeakKeyDictionary_structnode2type_options_int_constants _recomplete_uses_new_feature)selfs r__init__zParser.__init__)sT&)ee#"# ' 9 ; ;  !%rct|\}}t|}g}t|jD]K}|dr4|dd}||||L|t|z }g}|d|D]}|d|z|d|dtd||d|}tt  t |} n7#tjj$r } || |Yd} ~ nd} ~ wwxYwttn&#ttwwxYw| ||fS) Ntypedef z*# 1 ""ztypedef int %s;z@typedef int __dotdotdotint__, __dotdotdotfloat__, __dotdotdot__;z# 1 "r;r[)rwrsortedrr$r rCDEF_SOURCE_STRINGr&lockacquirerparserc_parser ParseErrorconvert_pycparser_errorrelease) rr'rpctn typenamesrE csourcelinestypename fullcsourceastes r_parsez Parser._parse3s%g.. !)) 4-.. " "Dz** "ABBx  &&& D!!!VC[[  HIII! > >H    1H < = = = =. / / / *<*<*<>???G$$$ii --   LLNNN --%%k22CC!, 5 5 5  ( (G 4 4 4 4 4 4 4 4 5   FG##s0!E*)G*F>FGFG#G%c$d}t|}tjtd|}|r_t |dd}|}d|cxkrt|krnn ||dz }|S)Nz:(\d+):r )strrer)rrUr"r=r%)rrr'rAmsgr)linenumrs r_convert_pycparser_errorzParser._convert_pycparser_errorYs!ff);););=sCC  /%++a.."--G"--//LG0000s<0000000#GAI. rc|||}t|}|rd|d|}nd|}t|)Nzcannot parse "z" z parse error )rrrdr)rrr'rArs rrzParser.convert_pycparser_errorgsf,,Q88!ff  - --1ZZ\\\\33?CC -(+s,CnnrFNc|r)|dkrtd|rtdd}n|r||dz zrtd|nd}|j} |||d|_||||_dS#||_wxYw)NTzB'packed' should be False or True; use 'pack' to give another valuez$cannot give both 'pack' and 'packed'rz#'pack' must be a power of two, not r )overridepacked dllexport) ValueErrorr_internal_parse)rr'rrpackr prev_optionss rrz Parser.parseqs  ~~ "@AAA I !GHHHDD  tax   jT" D}  ))1'+*355DM   ) ) )(DMMMLDM ( ( ( (s  A<< Bc ||\}}}||t|j}|D]}|jdkrnJd} d|_|D]}|}t |tjj r| |:t |tjj r|jstd|d}t |j j tjjr@|j j jddr||}nt |j tjjrt |j j tjjrst |j j j tjjrE|j j j jddr||}n/||j |jdd|jd  \}}|d |jz|| |jjd krtd|jjz|dS#t$r.} t3| jdkr| j|fz| _d} ~ wt6$r7} || |} | r| jdd| zzf| _d} ~ wwxYw)N __dotdotdot__r __cffi_extern_python_stopz!typedef does not declare any name __dotdotdotTz*(z *)0)rEpartial_length_oktypedef_examplerqualsPragmazBunexpected <%s>: this construct is valid C but not valid in cdef()rz *** Err: %s)r_process_macrositerextrE_inside_extern_python isinstancerc_astDecl _parse_declTypedefrtypeIdentifierTypenamesr$_get_unknown_typePtrDeclTypeDecl_get_unknown_ptr_type_get_type_and_quals_declare __class____name__r%argsrr) rr'rrpiteratorrF current_declrrealtyperrs rrzParser._internal_parses0#{{733VW V$$$==  DyO++, 1 ' )DD &  C C# dIO$899C$$T****io&=>>C9.'(K(,...E"49>9?3QRR G IN04?? NN G#'#9#9$#?#?$TY 0GHH G$TY^Y_5MNN G$TY^%8%._%CEE G).-3B7BB=QQ G $(#=#=d#C#C*.*B*B IDI:>))),E+C+G+G%MM*ty"8(%MPPPP^,88#%@$(N$;%<=ACCC5 C C:   16{{a3@BB B#&C   rc|d}|d}|r |dd}|dr(|dkr"|ds d|ddz}t|d}|r| }||||d|z|dS) Nul-r00x0or macro )lowerrstripr$rUrr)rrEint_strnegpyvalues r_add_integer_constantzParser._add_integer_constants--//((..  %%  "abbkG   s # # )3**400)7WQRR[(Ggq//  hG D'*** how/////rc 8|D]\}}|}t|r|||J|dkr|d|z|jt d|d|d|d|dS)Nr_rz5only supports one of the following syntax: #define z+ ... (literally dot-dot-dot) #define zM NUMBER (with NUMBER an integer constant, decimal/hex/octal) got: #define rZ)itemsrd_r_int_literalr)rrr)rrprvalues rrzParser._process_macross ,,.. . .JCKKMME##E** .**36666% hne4444issCCCee -... . .rc|||}|jdrd}n|jdkrd}n|jdkrd}nd}|||jz|dS)Nrzdllexport_python __cffi_extern_python_startzextern_python !__cffi_extern_python_plus_c_startzextern_python_plus_c z function )_get_type_pointerrgetrrrE)rtprrFtags r_declare_functionzParser._declare_functions  # #B . . =  [ ) ) %CC  '+G G G"CC  '+N N N)CCC cDIor*****rc|j}t|tjjrT|||j\}}t|tjsJ| |||dSt|tjj r| d|nt|tjj r| d|nMt|tjj r| d|n|jstd||jr1||d\}}|jr| |||dS|rpt#|dr`t#|jd rKt&|jjr'||j|jjdS|rt|jtjjr|jjd krrt#|jjd rXt&|jjjr/||jd |jjjzdS|tjur(|jd r|j|_dS|jd krtd |tjzr)|js"|d|jz||dStA||d|jz||dSdS)N)rEstructunionenumz'construct does not declare any variableTrinitrr__cffi_extern_python_rz>>>Y & I $&&&y P 44TGK5MM E%P**2ud;;;;;((**Pf--P 733P',,TY_==P..ty$)/JJJJJ((**P"49io.EFFP ++ 88,&,,TY^-ABB,..ty/2TY^5I/IKKKKKEO++i**+BCC, 26D...14OOO'ABBB -Pr7GP kDI&=r OOOOOGMMM kDI&=r OOOOOA P Prc8||dSr )parse_type_and_quals)rcdecls r parse_typezParser.parse_type's((//22rc6|d|zdd\}}|rJ|jdjjjd}t |t jjrtd|j d| |jS)Nzvoid __dummy( %s );rr zunknown identifier '') rrrrparamsrrrIDrrEr)rrrrpexprnodes rrzParser.parse_type_and_quals*skk"9E"ABB2A2F Vz72;#(/2 h  2 3 3 J)HII I'' 666rr c.||jvrI|j|\}}||ur||krdS|jdstd|dd|vsJ||f|j|<|r|j|dSdS)Nrzmultiple declarations of z5 (for interactive usage, try cdef(xx, override=True))r)rrrrsplitrr|)rrEobjincludedrprevobj prevqualss rrzParser._declare2s 4% % %!%!3D!9 GY#~~)u"4"4=$$Z00 >h6:dd=>>>djjll2222$'<4  1  ' + +C 0 0 0 0 0 1 1rcd}t|tjjtjjfrHd|jvr|t jz}d|jvr|t jz}d|jvr|t j z}|S)Nr constvolatilerestrict) rrrrrrrr  Q_VOLATILE Q_RESTRICTrrrs r_extract_qualszParser._extract_quals@s dY_5&_46 7 7 *$*$$&TZ''))TZ'')) rcpt|tjr|St|tjrZ|jdr@|jddr|j|tj |||Stj ||S)N$r) rrras_function_pointerStructOrUnionOrEnumrEr$isdigit forcenameNamedPointerType PointerType)rrrdeclnames rrzParser._get_type_pointerLs dE1 2 2 .++-- - tU6 7 7 A $$S)) A.2im.C.C.E.E A&8+?)$%@@ @ u---rc4 t|tjjrt|jtjjrxt |jjdkr[d|jjdz|jvr?|jd|jjdz\}}|| |z}||fSt|tjj rp|j d}n| |j |}||dkrd|d}d|z}| |j|| \}}tj|||fSt|tjjrN| |j\}} ||| | }| |}||fSt|tjjr| |}|j} t| tjjrt%| j} | d d gkri} | r/| d}|d vr | |ddz| |<| d=nn| /g} dD]=}t)| |dD]}| |>| sdg} | dgkr d| vsd| vrg} | | z} d| }|dkrtj|fS|dkrt1d|jjzt7||\}}|||zfSt| tjjr|d| |}||fSt| tjjr|d| |}||fSt| tjjr|d| |}||fSt|tjj r|!||dfSt|tjjr|d||ddfSt|tjjr|d||ddfSt1d|jjz)Nrrr rr_z_cffi_array_len(rr)rr)r0signedchar)shortlongr2unsigned)r6r4r5rUr4r5rZvoidrz:%d: bad usage of "..."rrrT)nestedz(:%d: bad or unsupported type declaration)"rrrrrrr%rrr' ArrayDecldim_parse_constantrr ArrayTyperrrjrranger r&r rcoordrArrrrrr_parse_function_type)rtypenoderErrrrlengthitemtype itemqualsrrprefixesnewnamesprefixr-identtp0quals0s rrzParser._get_type_and_qualsUs$ x!9 : :  x}io&D E E   # $ $ ) ) (--a0 0T5G G G*: 8KA8N+NOIB T((22 2Eu9  h  9 : : 6|#--L4E.GG *U???6EooGF"%"7002C0?1AAIB?2v..5 5 h  7 8 8 "&":":8="I"I Hi'')d'KKB''11Eu9  h  8 9 91 !''11E=D$  >?? -TZ((Xv...!H"$Qx#JJJ-5\\$-B-BQ-FHTN %a!  " "H"?44!&x||FA'>'>!?!?44A$OOF33334 (!&''"h..&H2D2D$&E$u,EF?? ?E11O++"#<$N/$01111$>> VUV^,,$  677 !55hdKK5y $  566 !55gtTJJ5y $  455 !55fdDII5y h  8 9 9 @,,Xt<\}}t |ds)t d|pd|dzt|ddfz?t |dkott|d jtj j oJt|d jjtj j o|d jjj d gk}|r*||st d |pdzfd |D}|s|tjgkrg}|j\}} d} t |jd r|jjddgdkrd} tjt)|||| S)Nrrzt%s arg %d: unknown type '%s' (if you meant to use the old C syntax of giving untyped arguments, it is not supported)z in expressionrrE?r rrz=%s: a function with only '(...)' as argument is not correct CcTg|]$}j|j%Sr) _as_func_argrr).0 argdeclnoders r z/Parser._parse_function_type..sD+++"!4#;#;KKLMMM| *   j ) ) ) < =C27NN MM.2<7 < < <&(d# 6>>I : I ; "@4GHH H J # #D49io&DEE GGDIO,,??""2v...|#..t|<<#(D 2249EI3KKKD%# /""2v...$ 011 /dl /""2v... OODIO , , , OOD ! ! !   g & & & OOE " " " "Hoo Hoo j)) Hoo "J/ / /"e.// 3BJ 3)-/RR+2333M%%h// < (BL   # #B ' ' ' s  ct|tjst|d|s|st |dd|_dS)Nz cannot be partialz is partial but has no C nameT)rr StructOrUnionr has_c_namer7ri)rrr8s rrfzParser._make_partial_se"e122 <bbb:;; ;}} Pv P%"""&NOO O rct|tjjrr|j}d|dcxkrdkrnn|d} |drt|dSt|dS#t$rzt|dkrd| ddd krt|d cYS| ddd krt|dcYSYnwxYwtd ||dd krS|dd krGt|dkst|dkr!|ddkrt|dStd |t|tjj r%|jdkr||jSt|tjj r&|jdkr||j St|tjjr |j|jvr|j|jSt|tjjr2|jdkr'|r d|_dSt+d|jjzt|tjjr||j}||j}|jdkr||zS|jdkr||z S|jdkr||zS|jdkr|||S|jdkr|||||zz S|jdkr||zS|jdkr||z S|jdkr||zS|jdkr||zS|jd kr||z St+d!|jjz)"Nrr 9uUlLrrrrr0bzinvalid constant rrr \+r__dotdotdotarray__Tr_zT:%d: unsupported '[...]' here, cannot derive the actual array length in this contextr/%z<>&|^z?:%d: unsupported expression: expected a simple numeric constant)rrrConstantrrr$rUrr%rrordr r r;r rrErrhrr>rABinaryOpleftright_c_div)rrrrVrrs rr;zParser._parse_constantfs h  8 9 9 >Aad!!!!c!!!!!HHV$$ -||C((*"1ayy("1bzz)!---1vvzz7799QqS>T11#&q"::---WWYYqs^t33#&q!99,,, -  i <===12#FFaKKCFFaKKAaDDLL1R5zz!i <=== x!8 9 9 7 s""'' 66 6 x!8 9 9 8 s""((777 7 x!3 4 4 6 !444&x}5 5 x!3 4 4 2M%999  '+$uE%^0122 2 h  8 9 9 $'' 66D((88E{c!!e|###e|###e|###{{4///##dkk$66>>>$$u}$$$u}$##e|###e|###e|#13;>3FGHH Hs$B 9B A D 0D  D cF||z}|dk|dkz r||zdkr|dz }|S)Nr rr)rabrYs rrz Parser._c_divs:a Uq1u  AEa<< aKF rc|d}g}g}d}|jD]}t|jrd}$|j||j}||j||||j||dz }t|}t|}tj |||}||_ ntj |dd}|S)NFr Trr) enumerators_r_enum_dotdotdotr)rErr;r rrUrEnumTyperi) rrprdrir enumvalues nextenumvaluerrs rrazParser._build_enum_types  GKJM) # #$**4955"G:)$($8$8$D$DM""49---!!-000##DI}==="  ,,Kz**J {JGGB BJJ r266B rcR|jD]W\}\}}|dr|ddd}|dvr|||d|X|jD]\}}|||dS)Nzanonymous $enum_$rZrr )rrr anonymousrzT)rr)rrr$rrrr)rotherrErrrnkvs rincludezParser.includes!&!4!:!:!rA)rrFrs rrzParser._get_unknown_typesIN( ) ) )%di00 0 +, , ,%-)>)J&+DI66 6 -. . .%-)@49)L&)$)44 4C)** *rc|jjjjdgkrtj|jSt d|jjz)Nrr)rrrunknown_ptr_typerErr>rA)rrFs rrzParser._get_unknown_ptr_typesN 9>  $(9 9 9)$)44 4C)** *r)FFNF)Fr r)NFN)NF)F)r __module__ __qualname__rrrrrrrrrrrrrrr'rrr?rMrrfr;rrarrrrrrrr's&&&$$$$$$L   AE#))))0555n''' 0 0 0..." + + +1P1P1Pf333777 1 1 1 1   ....JO,0g%g%g%g%R!I!I!I!IFttttlGHGHGHGHR 0&&&***&*****rr)4rr commontypesrrerrorrrrr ImportErrorrrsys version_infothread_thread allocate_lockrrrcompileDOTALL MULTILINEr`rarNrkrrir}r IGNORECASErrgrfrhr5rrnrorr/r9rBrGrPrWrwrobjectrrrrrsM::::::::&&&&&&&&))))))) $      7 " "DD DDD, RZ7 BL022 RZ2 BL022 BJA2<PP"*=>>BJ3442:122 2:i  4bmDDbj233 bj677 2:n % %2:OPP bj.002:())RZ <== (((T000d   ;;; $ $ $333@@@D%%%PG *G *G *G *G *VG *G *G *G *G *s ++#AA)(A)